Last updated January 22, 2014. Created on March 8, 2013.
Edited by heliogabal, discipolo, Cellar Door, osopolar. Log in to edit this page.

Extensions: Layouts

  • Your theme can use multiple layouts, each of which which is kept in a subfolder of 'mytheme/layouts/'.
  • To get started with your own layout, you can copy the Omega layouts folder into your sub-theme but you'll need to rename the layouts to something different. The regions declared in your subtheme.info file must match those in your .layout.inc file. Please see Creating A Custom Layout for more information.
  • A layout is an alternative to the main 'mytheme/page.tpl.php' file.
  • The default layout for your theme can be selected on the theme settings page.
  • The active layout of a given page can be changed through custom code, a Context module reaction (see the Context Omega module) or through Panels. This is useful for loading different layouts on different sections of your website.
  • The two main elements of a layout are
    1. A .layout.inc file that describes the layout. The structure of a .layout.inc file is similar to the theme .info file (name, description, and declaration of stylesheets and JavaScript files).
    2. A page.tpl.php file that provides the HTML structure for the layout
  • Using a layout adds a new layer of complexity. Try to keep the structural CSS, scripts, templates... separate from the more global theming of the site's look and feel. Keep all layout-related files in the layout sub-folder and the design files one level up in the theme folder.

Yet Undefined/In-Progress:

  • Extensions: Libraries
  • Extensions: Development
  • Extensions: Compatibility

Looking for support? Visit the Drupal.org forums, or join #drupal-support in IRC.

Comments

OnkelTem’s picture

The active layout of a given page can be changed through custom code, a Context module reaction (see the Context Omega module) or through Panels. This is useful for loading different layouts on different sections of your website.

Please, provide code snippet!

rootop’s picture

some code snippets to set the layout programmatically would be great.

discipolo’s picture

DrupalFrank’s picture

Is there a way to declare one of my layouts as the default layout for my omega 4 subtheme via a setting in the info file?

I'd like my custom layout installed into "layouts/admin" folder to be the default layout when my custom subtheme (called "raptor_omega") is selected. I tried various things to declare the admin layout as the default including the following addition to my raptor_omega.info file but nothing seems to do the trick...

settings[omega_layout] = "raptor_omega-admin"

I also tried simply assigning "admin" but that did not do the trick either.

Thanks in advance for any information.

DrupalFrank’s picture

I added the following hook into my custom theme's template.php file...

function raptor_omega_omega_layout_alter(&$layout)
{
if (arg(0) == 'worklist')
{
$layout = 'worklist';
} else if (arg(0) == 'protocol') {
$layout = 'protocol';
} else {
$layout = 'admin'; //Default layout
}
}
miller2676’s picture

I would like to prevent users from choosing a layout from Omega and Ohm and only make available the custom layouts in subtheme-x. Is these a way that I can alter theme-settings.php to only look for themes in subtheme-x?