I'm using taxonomy term pages for a directory type application where I use the "taxonomy menu" module to list out links to taxonomy term pages that display teasers of content related to each term. That works just perfectly for my needs.
I'm having trouble with applying blocks to the term pages...
I would like to use blocks to apply theme/design elements to term pages and have them display based on their absolute parent term. I have 3 first level parent terms that split off into their own distinct multi-level branches as follows:
1stLevel
--2ndLevel
----3rdLevel
1stLevel
--2ndLevel
----3rdLevel
1stLevel
--2ndLevel
----3rdLevel
Since the term pages don't have the full path in the url, I can't use a wildcard and display for "Only the listed pages". The alternative is to use PHP and find the parent term but that seems a bit messy because if you are on the parent term, taxonomy_get_parents($tid); returns nothing and if you are in the 3rd level, the parent term is the 2nd level.
I've done a fair bit of "googling" over the past 3-4 days with nothing to show for it. I'm not choosey about how I solve it but maybe someone else can nundge me in the right direction.
Thanks,
Andrew
Comments
forget the core block system
forget the core block system and use http://drupal.org/project/context. You can use taxonomy as a reaction to display blocks that u need
Update: A Solution
Well, I put this on the backburner for a while and came back to it this morning with a fresh outlook.
NOTE: This isn't for regular content pages, this is only for the taxonomy list views where you have a list of terms under some hierarchy of terms and all of the content titles and teasers relating to that term are listed below. I am using the terms pages as a directory of sorts to list out and organize content.
My goal was to create some sort of code mechanism that would give me the absolute parent term for any leg on a taxonomy listing page . So even if the titles and teasers I'm looking at are five levels down from the main term, I want to be able to identify the first level parent term (in code) so that I can apply it to body classes or use it to display a block.
There is probably an easier method or a module somewhere but I couldn't find it so I coded the following. Hopefully it will help out someone else in the future.
Update with preprocess_html() code
One more update:
The following code will add a CSS class to the body classes collection so that all of the term list pages under a 1st level term can share common CSS attributes and behaviours.
Using preprocess_html() code
Works for me (:
Parent Term to Node Pages
Hi guys,
Could any one shed some light on how I could print the parent term of a term that is assigned to a node to the body classes_array? I've been searching through forums all day and can't seem to find the solution. I have been able get the assigned term to print to the body class using the following code:
Added this to template.php in bootstrap:
Added this to the html.vars in bootstrap:
Any help would be truly appreciated!