By choline on
I have a page.tpl.php and I want to customize a section of the html so that it displays specific info for each page.
So, in a certain div, I want specific information related to that page to show.
My current solution is this:
In my template.php, just have a large switch statement that depends on the filepath. This then passes a template variable w/ my page specific info to page.tpl.php.
So, every time I add a page, I'll have to add another statement in the switch clause.
This just seems so inelegant, there must be a better way that I just can't think of right now.
Any suggestions? Is there some feature of drupal I'm overlooking?
Comments
It looks like some form of
It looks like some form of switch is required somewhere even if you move the logic out into a module. (Using
hook_node_api($op = 'view');)A dynamic solution is something like:
Harder, but even cleaner, is to add a custom FAPI field to the content type form. I would not be surprised to find a module that does this already.
Alan Davison
If the relation can be used
If the relation can be used by views and the information you want to display is available to views you could make a view that takes one argument (you will need to set default handling) and has a block display that you could then enable in a region.
You could also create a block
You could also create a block with php enabled for the input format, and set your logic in there. It would save having to re-upload your template.php file every time you create a page - you can just edit the block through the admin interface.
Contact me to contract me for D7 -> D10/11 migrations.
Context module?
Apparently, http://drupal.org/project/context also can be configured to do this. I haven't used it personally.
Alan Davison