1

I am using Omega 3.x along with Delta and contexts for creating a drupal theme for my site. I have experience with using D6 themes like Zen but I am still learning my way around Omega.

I want to know how I can create and name a separate template for my zone called content for the front page. I wouldn't mind a hard coded or a Delta+context solution or for that matter any other method to achieve my goal as long as Omega is used.

3 Answers 3

6

This was too much for a comment so I put it in an answer. newdwardss's answer contains the right methodology, but it doesn't address the Omega theme.

You can use the same logic as in that answer, but customise it for the zone template:

function MYTHEME_preprocess_zone(&$vars) {
  if ($vars['zone'] == 'content' && drupal_is_front_page()) {
    $vars['theme_hook_suggestions'][] = 'zone__content__front';
  }
}

That will allow you to use a template file called zone--content--front.tpl.php which will only be used for that zone, and only when on the front page.

2
  • i added the above function to my template.php file, but it did not make any difference. Am I missing out on something?
    – bcosynot
    Aug 21, 2012 at 19:53
  • oh wait, did not clear the cache properly. this works now, thanks a lot!
    – bcosynot
    Aug 21, 2012 at 19:56
1

Your front page only template should be called:

page--front.tpl.php

and/or you could get more custom via:

<?php
function YOUR_THEME_NAME_preprocess_page(&$vars) {
if ($vars['node']->type == 'content'){
    $vars['theme_hook_suggestions'][] = 'page__content';
}
}
?>

But in your case you may need to switch on a different part of the $vars['node'] object that references your "zone".

See Drupal 7 Template Suggestions for a full reference (quite handy).

For clarity, by "zone" do you mean region? If so, you can implement the above page--front.tpl and then call your custom region tpl output on that page--front.tpl only.

3
  • 3
    "Zone" is a specific thing in the Omega (or more specifically the Alpha) theme, it sits one level above regions
    – Clive
    Aug 21, 2012 at 13:57
  • 1
    Clive's answer is superior. The above did not take into account the zone in Omega (Alpha) theme. My apologies.
    – nedwardss
    Aug 21, 2012 at 14:42
  • I was already aware of the page--front.tpl.php - that was actually the first thing I tried and as was pointed out, it does not work for a theme based on Omega.
    – bcosynot
    Aug 21, 2012 at 17:40
-1

For use with the region content template (region--content--front.tpl.php) use this instead:

function YOUR_THEME_NAME_preprocess_region(&$vars) {
  if ($vars['elements']['#region'] == 'content' && drupal_is_front_page()) {
    $vars['theme_hook_suggestions'][] = 'region__content__front';
  }
}
1
  • Hello and welcome. I don't think this really answers the question asked here. And I'm pretty sure that question like this, but about regions, was already asked on this site.
    – Mołot
    Aug 22, 2013 at 11:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.