Dev:Theme Areas

From Habari Project

Jump to: navigation, search

Areas are places in a theme's templates that are designated to render block content.

See also Blocks.

Contents

Designating Areas

To designate an area as open for block display, add the relevant contexts and areas to the theme's xml:

<theme>
  <name>K2</name>
  <author>K2 Team</author>
  <url>http://getk2.com/</url>
  <version>1.0</version>
  <template_engine>rawphpengine</template_engine>
  <description>A port of the popular design K2 and first Habari "theme"</description>
  <license url="http://www.apache.org/licenses/LICENSE-2.0.html">Apache Software License 2.0</license>
 
  <areas>
    <area name="sidebar">
      <description><![CDATA[The sidebar area]]></description>
    </area>
    <area name="nav">
      <description><![CDATA[The navigation area]]></description>
    </area>
  </areas>
 
</theme>

Displaying an Area

To output an area, echo the area method on the theme object, and pass it the name of the area to render.

<?php echo $theme->area('sidebar'); ?>

Contexts

Admins have the ability to change the blocks that are displayed (and the content fed to those blocks) in any area based on criteria they set, such as the slug of the post being displayed, whether the page is an archive, etc.

An interface will exist in the admin to configure these settings, and no specialized code is required to implement this feature.

Block Area Templates

Theme developers may provide additional templates that are specific to areas in the theme so that block content is output differently. A list of fallback templates is currently on the Blocks page.

http://screencast.com/t/NDY3ZWExZjM
A movie demonstrating how area contexts can be applied to filenames to allow for fallback templates.
Personal tools