The 4Site Blog

Homepage template quirks in Drupal 7

bjones

So it's time to theme another Drupal site. You've got your base theme installed, customized, and ready to roll (we like to use Zen). You've got your interior page template styled and slick, now comes the homepage...usually a bit different from the rest of the site design.
In Drupal 6, everything is pretty straightforward in terms of how you set up your homepage template from the default interior page template (duplicate the page.tpl.php file and call it page-front.tpl.php and make sure both are uploaded), set blocks to display (or not) based on simple logic and options within the block editing area, etc. In other words, everything behaves as expected...smoooooooth sailing.

However, when going through the same workflow in Drupal 7, I noticed some things seemed amiss and not documented very well. I discovered after much research that to create your homepage template and have it register as such, you now had to use a double hyphen in the nomenclature mentioned above: "page--front.tpl.php" versus "page-front.tpl.php" which felt random.

I also noticed that page content was being controlled by a new block called "Main page content" which could be dragged into a preferred region to populate the site with content. Great! Once I was ready to set up the homepage, which didn't need any type of dynamic content "loop" pumped in, I went into the block settings and told it to display on every page except the front. Then I set up all my homepage-specific blocks and set them to only display on the homepage. Voila.

Unfortunately the content block was still populating the homepage with mysterious information despite my settings above instructing it to go away. After numerous refreshes, cache flushing, double and triple checking code, pulling out hair, etc. I realized I was doing everything right...but it still wasn't working. Digging around online, I stumbled across a forum full of people with an almost identical problem: how do we turn off this content we don't want in the homepage content region?

As noted in comment #48, the best solution I could find and wanted to share was to create a custom region for the homepage which wouldn't be present on any of the interior pages, thereby removing any possibility that content I didn't explicitly place there would ever show up. I removed the "content" region from the homepage template and replaced it with something obvious like "content_home" and updated my .info file to define this new region. After pushing these updated files to the development server and flushing caches, I was able to drag the "Main page content" block and any other blocks I wanted on interior pages only to the regular "content" region and blocks I wanted on the homepage to the "content_home" region. No more fooling with the "show on every page except <front>" options per block that were being ignored, etc. This has worked like a charm for me, and I've tried to share my method with colleagues as it comes up in new projects.

If you poke around the forum link above, you'll see alternate ideas and suggestions, some of which may be good solutions as well. Let us know if you've had similar experiences with quirky Drupal behavior and how you tackled them!

3D Workflow: Production with an Added Dimension

asmith

Three-dimensional video can make for an amazing, immersive viewing experience, whether at the theater, on TV, or on the Web. There are various viewing technologies available to watch video in 3D. Stereo Anaglyph is the most common for television and web-based videos, which pair with the traditional Red/Cyan glasses. As technology develops, this is changing with the introduction of 3D TV's and...

Join Our Team: ISO Talented Project Manager

hnelson

4Site Interactive Studios, a Drupal design and development firm located the Columbia Heights neighborhood in Washington, DC is looking for a fun, talented and organized individual to join our team. This dynamic company invests greatly in its employees and provides a flexible and supportive work environment.

As Project Manager, you will help to streamline and improve upon an already...

Measure Twice, Cut Once

bjones

It's an old maxim in carpentry that you should double check your plans and measurements before actually constructing anything. And with good reason. Changing your mind after you put saw to plank is tantamount to starting over. Once you cut a board, you can't make that board longer. And often times, that's the same with Web development.

3 Easy Steps...

Building a website...

Integrating Drupal with Your Salsa Supporter Database

admin

4Site Interactive Studios released a Drupal module that syncs user data between the Salsa database (www.democracyinaction.org) and the Drupal platform. The module is being used on www.EdExcelencia.org, and it allows Excelencia in Education to fully integrate their...

Screen Printing, You Move Me

bjones

Inspiration is an important part of the design process for any creative person. We all get excited by different things: some people love taking long hikes and appreciating nature, some like going to galleries and seeing pieces of sculpture and paintings that move them, some people use "recreational substances" to get inspired. But as a design geek, my secret passion is silk screen posters....