Hi,
I'm using Drupal 7, and have created a subtheme for Bartik. I would like to customize the template for the book module. I was able to create a custom node template using the filename: node--book.tpl.php , but I'm not able to create a custom page template for the book module. I've tried different file names like:
* page-book.tpl.php
* page--book.tpl.php
* page-node-book.tpl.php
but no luck.
Using the theme devel module, on clicking the page elements, I'm surprised to see it's referencing the file html.tpl.php on the book pages, while on other pages the same area it references page.tpl.php.
So I'm confused what to do, how to create a custom page template for a content type (like book) in D7 using a subtheme.
thanks
Comments
Update
Ok, I was searching around for solutions and realized that templates.php needs to be modified for Drupal to be able to create custom page templates for content types. I came across this code:
http://adaptivethemes.com/page-template-suggestions-per-node-type
and have added to template.php of my Drupal 7 Bartik sub theme. But no luck :(
The code in the above link is for Drupal 6. Is it compatible for Drupal 7?
...
I updated that post to include a snippet for Drupal 7, the main different is that we now use theme_hook_suggestions and the syntax is slightly different for templates - use two hyphens instead of one:
Pimp your Drupal 8 Toolbar - make it badass.
Adaptivetheme - theming system for people who don't code.
Hi Jeff, That worked! Thanks,
Hi Jeff,
That worked! Thanks, you're too cool! B-)
Thanks, I added 'node__' to
Thanks, I added 'node__' to avoid conflicts with custom (Views) paths.
thank u!!
thank u!!
Plain and simple, thanks! now
Plain and simple, thanks! now i can do page--node--product!!! and my views pages paths still work.
Great!
That's works fine
Thank You very much.
Thanks and a tip on sidebars
Thanks Jeff, that worked for me too!
For anyone wanting to remove sidebars from their alternative page layout, here's a useful article it took me a while to find:
http://www.lullabot.com/articles/drupal-performance-tip-block-visibility
(Despite the article name, it's not only a "performance tip": it explains some stuff about classes and CSS which you might need in order to make the sidebar disappear properly.)
thanks jeff its working
thanks jeff its working fine........
Anyone with any ideas?
Anyone with any ideas?
I'm interested in this too,
I'm interested in this too, will run some tests later today. For the moment, try replacing &$vars with &$variables and see it makes any difference.
...
$vars is just a short version of $variables, it depends which one you declare as the parameter in your preprocess function, for example the following two examples are both correct:
Pimp your Drupal 8 Toolbar - make it badass.
Adaptivetheme - theming system for people who don't code.
Thanks for mentioning the
Thanks for mentioning the filename for custom node template. That solved my problem. :)
drupal 7 where to paste
I'm sorry and I'm pretty new to this stuff. Where exactly should I paste on the template.php? I've tried numerous from top to bottom and I got errors. After paste the code is there any extra steps I need to know?
thanks..
Could this be done from a
Could this be done from a module so we dont have to update the theme template.php every time there is a new version?
My Drupal sites: