Closed (fixed)
Project:
Zen
Version:
6.x-2.0
Component:
Miscellaneous
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
30 Aug 2009 at 19:32 UTC
Updated:
21 Aug 2013 at 08:59 UTC
What's the recommended approach for theming the front page in a Zen sub-theme, when I want to be able to -
* Place additional containers in the body/guts of the page
* Include content from other nodes in those containers (the content would be snippets from stories, such as a 'Featured Story' and a 'Latest Story')
I'm leaning towards creating a separate page-front.tpl.php. Other options appear to be using the Front module, or some other module that allows the front page to be changed.
Suggestions are welcome.
Comments
Comment #1
hokuspokus commentedThe page-front-tpl.php is the most versatile approach, allowing you to construct the layout how ever you like. You can also add new regions and rename the divs to whatever you need as well. Much more efficient than trying to kludge something together using panels or other module based solutions.
Comment #2
nevets commentedWhile that is one approach there is nothing kludge like about panels. It has the advantage of allowing to control both the layout and content from the UI.
Comment #3
hokuspokus commentedI'm sorry, I'm not dissing Panels in any way, it was my go-to solution for building until I needed to create some pixel perfect layouts. Creating your own divs using a custom page.tpl.php gives you finer grain control over how elements and blocks line up together, Panels can do it, but I was advised against using it for that purpose.
Comment #4
mark. commentedFor the record,
page-front-tpl.phpdoesn't work.page-front.tpl.phpdoes though.Comment #5
jan_v commentedWith this approach, is it also possible to define css files only used on the frontpage ?
Comment #6
hokuspokus commentedYes,
You would create frontpage-specific div id's and classes to section off you content that you could target with CSS. So for example, here's the content area from Zen's page.tpl.php:
Everything is wrapped in a div with an id of "content", with all the Drupal guts created with the php command ?php print ( print $highlight, print $messages, print $content_top, and the ever important print $content).
You duplicate the page.tpl.php file and rename the copy page-front.tpl.php (or use devel to find a candidate name) then you can change the order of the php printed items, wrap them in new divs, and add or delete them- adding new or altered CSS id's as you go to suit your theming needs in the new front page template.
Comment #7
smrogers commentedHow do I edit a Zen subtheme so the layout is different for the front page? I would like to use page-front.tpl.php with three columns and page.tpl.php with 2 columns (of different sizes, deleting the print of a column will not do the trick)
From what I can tell, I would like to have page-front.tpl.php call sidebars-front.css and and page.tpl.php use sidebars.css if this is possible (and will accomplish my goal).
I can speculate of how to do this (e.g. through page-front.tpl.php or my .info file), but my inexperience likely leads to poor speculation, and any assistance would be appreciated. Thanks.
Comment #8
hedley commented@smrogers - you could do a lot of this using CSS.
If you use the block display settings so that blocks appear in sidebar-first, content & sidebar-second regions on the front page, and then make sure they only appear in two of the regions throughout the rest of your site - you could use the .front class to change the sizes of the sidebars / content area on the front page so the regions are have different widths and creating a different layout
Comment #9
johnalbin