By vthirteen on
the new PHP block visibility settings feature seems to be very useful http://drupal.org/node/60317
i need one block to be displayed only in nodes associated with one vocabulary - which means a number of taxonomy terms.
which PHP snippet should i use or how can i modify the snippets provided in the "Associate Blocks with Forum nodes" & "Display block only for forums" pages?
thank you
Comments
show block on specific pages
this feature is really very useful.
i use block visibility settings to restrict google ads showing on some non-content pages, for example, admin pages, user login, etc
but i'm not very experinced with PHP so I'd like to get to know PHP syntax of boolean expressions...
See my page as working example
thanks
control block visibility with taxonomy
there's probably an easier way to do this but...
if you wanted to look for term id instead of term name, just say $term->tid.
if anyone knows of a built in function that gives you an array of term names or term ids when passed a node id or node object, please let me know!!!
you could also construct this as an SQL query, i guess.
Worked perfectly
Thanks firebus, I needed a code snippet to make a block target a taxonomy view, and that worked perfectly. I used $term->tid
A similar snippet using path aliases
Here's a similar snippet using path instead of taxonomy term.
$startlist is an array to match what areas the block should appear on
$endlist is an array to match areas within $startlist that will hide the block
for instance, if you have a section called "staff" and have a contact page under "staff/contact" and "staff/about", putting "staff" in $startlist and "contact" and "about" in $endlist will show a block on all areas of "staff" except "staff/contact" and "staff/about".
Thanks
Love this script - thank you!
The Context Module solved
The Context Module solved most of the issues without PHP. Excellent module.
http://drupal.org/project/context