Filter Page List by a custom select attribute1 user found helpful
Program has the options:
Agricultural Engineering Technology, etc...
I'm trying to create a custom template for the page list block that will only show pages that have a specific option selected from the program attribute, for instance "Animal Science".
So I thought that this line adapted from the documentation would filter my page list but unfortunately it hasn't.
I've searched the forums and turned up some interesting discussions but they all seem to be not quite what I need or WAY over my head. I'm not even sure where to put the above code (put it in the controller above the other filters, didn't do anything).
I've been racking my brain over this for the past two days so any help would be greatly appreciated.
You might want to try this free block I posted to another forum thread which is very similar to what you want to do (but I called it "Related Content" instead of "Program"):
I think if you install that and then go to Dashboard -> Pages and Themes -> Attributes, and change the name of the "Related Content" attribute to "Program" (but leave the handle as-is), that should do the trick. If you already have the Programs entered into the content of your site (like you already built out the site and assigned programs to pages), then it's going to be more challenging -- will require altering the code of that addon.
Also there's a paid addon that does a similar thing, which might be a bit more polished than the free one I linked to (but I haven't personally used it myself so I'm not sure what its capabilities are):
If one of the "program" page attribute values is "Animal Science", but you filter for "animal_science" how would that work since select value handles aren't based on the values themselves?
Shouldn't you use?:
$pl->filterByAttribute('program', 'Animal Science');
EDIT: BTW, Jordan is right, making a custom template wouldn't help for the reasons he stated. Unless you want to programatically make the block or manually utilize the PageList model yourself, you're out of options.
$pl->filterByAttribute('program', "\nAnimal Science\n");
to the controller of the page list block and it worked. I guess i may just have to take the plunge and figure out how to make a custom block. The project I'm working on is for the university where I work and I wanted to get this up and running with out having to go through the red tape of requisitioning 20 bucks or whatever to pay for an add-on.
Thanks for the help and if anyone has any other suggestions I would appreciate it.