Hi all,
I've been trying to figure out a way to get all the nodes that belong to one menu to all use the same .tpl.php file but I can't seem to find any answers. The idea being that I would have an 'about us' section, all the nodes that 'belong' to the about us area are listed in a menu in the left sidebar. I was hoping there would be an easy way to designate that they all use the same template file - i.e. so they all display only the 'about us' navigation menu and not the site wide navigation menu. I suppose I could just make copies of the template file and change the node number, but then that gives me 10 or so template files all doing essentially the same thing - it just seems like there would be a better way.
Any links or thoughts would be greatly appreciated. Thanks
Comments
Just reverse what you are
Just reverse what you are trying to do:
Create a new content-type. And all the pages that you need to theme in a particular way should belong to that one content-type. Then you can theme the new content type using tpl.php. Then you can provide links to all of those pages from within a single menu.
Ahh Thank You
Yep that is exactly what I was trying to do. I will get started on that right away. Thanks for your quick reply btw!
There are a couple of
There are a couple of possibilities that immediately spring to mind. None of them are perfect, but better than making 10 copies of the template file.
If you are only interested in changing the visibility of the menu and aren't trying to theme the rest of the page differently, you can divide your menu into multiple menu blocks and display different ones on specific pages or groups of pages. If you go to the 'Show block on specific pages' section in the block configuration, you can set what paths the block should display on. For example, if you're using the path module and all your 'about us' page URLs start with about-us/, you could create a menu block that will only display on 'about-us' and 'about-us/*'
------------------------------
http://fraggles.artsci.wustl.edu (Drupal user documentation and development blog)
Very Interesting
I kind of the like the idea that the previous poster made - but I'm really interested in the idea that you posted. I'm completely new to drupal, so it seems that everyday something new and interesting crops up. I hadn't even heard of the path module until just now - so I enabled it and played around with it a little bit and it looks like your suggestion of showing/hiding block depending on path will come in handy at some point. So thanks for that suggestion, I'll have to keep that in my back pocket for when an issue presents itself to use that with.
Glad to help :)
------------------------------
http://fraggles.artsci.wustl.edu (Drupal user documentation and development blog)
This is actually pretty easy
This is actually pretty easy to do, provided all your pages/nodes have the url like: mysite.com/about-us/node-title
What you can do is use
phptemplate_preprocess_page()to create new template "suggestions". The tutorials link in my signature - there's a tutorial called "Extended templating" that does exactly this.You can just setup the URLs to be in the above format, then copy/paste the
phptemplate_preprocess_page()function from the tutorial, and create thepage-about_us.tpl.phpfile. Now all nodes in the about us section will use that particular template file.---
Yuriy Babenko
www.yubastudios.com
My Drupal tutorials: http://yubastudios.com/blog/tag/tutorials
---
Yuriy Babenko | Technical Consultant & Senior Developer
http://yuriybabenko.com
Ya know - after I read both
Ya know - after I read both previous suggestions I got thinking that something like what you suggested would be a good idea - then everything could be themed based on what area it 'belongs' to. So I did some searching on how to write a template to work the url alias and found an article in the drupal handbook about getting drupal to recognize templates based on URL aliases. And now that I look at it, its the first function you have listed in your drupal 6 examples.
So I put that code into my template.php file and it worked like a charm. So now I'm in the process of adding URL aliases to my content.
But on a side note - what exactly do the other two snippets you have posted on your site do? I see the names are phptemplate_preprocess_node() and phptemplate_precprocess_block() - so I'm going to guess it has something to do with theming individual nodes or blocks? But thanks again for your suggestion - had I not already done some searching for that technique, this post would have a been an enormous help to me.
The node and block functions
The node and block functions do something very similar but for nodes and blocks. They essentially create more template suggestions based on node and block properties.
---
Yuriy Babenko
www.yubastudios.com
My Drupal tutorials: http://yubastudios.com/blog/tag/tutorials
---
Yuriy Babenko | Technical Consultant & Senior Developer
http://yuriybabenko.com