I have the following problem:
I'm trying to make a sub-theme to the popular Zen theme which will have a custom front page. I want to use a separate template file for my homepage, so I tried using page-front.tpl.php, but it just doesn't work.
If I put page-front.tpl.php in Zen's directory and set Zen as the default theme, the custom front page works fine, but if I just put it in my sub-theme's directory, where it should be, nothing happens, it's just ignored. I've tried "Clear cache data", I have both the base theme and the sub-theme enabled... just don't have any clue what I should do now.
Should something in template.php or .info file be changed? (don't think so, but I'm really deperate and to the point of just giving up on drupal, after seeing that too many things that should "just work" seem almost imposible or extremely complicated in this cms...)
Comments
create a page-default.tpl.php
Hi,
Copy all the code from your page.tpl.php, create a new file called page-default.tpl.php and paste the code in there.
Now delete all the code from your page.tpl.php and add the following:
That should work.
thanks a lot
thanks! it works ...but I wonder: is this the "normal" way to do it? I mean, is there a reason why things work without this in a theme but not if you're sub-theme-ing? Is it a "design error" of PHPTemplate or is this how things are supposed to work for some reasons that are beyond a newbie like me?
...or maybe I should just stop asking myself stupid questions and go get thing done :)
This will work in any theme
Hey, glad this worked for you.
This was one of the first things i learned when i started Drupal. This approach will work with any other theme as well.
This will keep you very much in control of what templates you want to use in different scenarios. You don't want to have too many conditional statements in one template as it becomes difficult to manage.
Using this approach you are taking advantage of the PHPtemplate engine that allows you to override templates.
Have fun and try and test it with content types, separate admin template etc.
Thank you!
I was having the same issue developing a subtheme with zen. Your solution worked like a charm! Thank you, thank you & thank you. :-)
tech | tech | food
And for the CSS going with
In the the template.php of the subtheme add something like :
--
Julien MARY
hi, i have done exactly what
hi, i have done exactly what you said. however, my front page is used, but after i login, the page-front.tpl.php template is still being used..how do i get it to use page.tpl.php after logging in?
thanks
See this -
See this - http://drupal.org/node/321845
You have to have a page.tpl.php for the page-front.tpl.php to work. I was having a similar problem of page-front not being used. Adding page.tpl.php to my sub-theme made it work.
Thank You!
Anyone else having this problem, this solution worked for me, and is a lot simpler/cleaner/more "proper" etc. than the first suggestion -- not to knock it, evidently that worked too, but now I won't fear my Zen theme breaking on a future update...
Whoops, and evidently we noobs need to read the documentation more closely! (We weren't the first to have this problem.)
I've also been tripped up by
I've also been tripped up by this before.
Do you think this is a bug of Drupal theme system? If it can't find page.tpl.php in a sub-theme surely it should fall back to the parent's page.tpl.php Is that not the point of having sub and parent themes?
I'm using Drupal 7 and
I'm using Drupal 7 and zen-7.x-3.x-dev, in order to customise front page, together with the solution above, the front page must be named as [page--front.tpl.php] (2 dash). HTH.
Thank you
Hi hvan021,
Thanks for that solution that was the easiest and worked like a charm
I believe, Clear cache is
I believe, Clear cache is also needed.
I tried to clear the cache it
I tried to clear the cache it worked, but there were problems with all the menu items now uses the node/id URL and not the alias that is specified on the node and in the url_alias.
Why is this happening?
It there any other way of just clearing the theme cache and not effecting everything else?
Thanks for sorting my page-front issue out
It's page--front not page-front: now it works!!!
Thank you