Create layouts with blank spaces using the Force Positions function to allow for more complex layout customizing. Find out more...

Home DocumentationWordPressCustomizeAdding Widget Positions

Adding Widget Positions

This section covers how to add a new widget position to the Gantry Framework and to your Gantry enabled theme.


Widget Positions

Check out this quick screencast on Widget Positions to get an overview of how widget positions work within Wordpress and the Gantry Framework.

Step 1: Getting Ready

Determine the position name and location on your theme where you would like your new position to appear. In our example we will use "example".

Step 2: Adding Position to index.php

Open your theme index.php file and go to where you would like to add your new position. Using $gantry we will make a call to the object using the function displayModules(positionname,widgetlayouttype,widgetchromelayout); This call will need to be echoed.

Example:

  
<div id="rt-exampleposition">
  <?php echo $gantry->displayModules('example','standard','standard'); ?>
  <div class="clear"></div>
</div>

  

The position now will appear after we have configured the Gantry portion to recognize it. Until then it will not work properly.

Step 3: Adding Position to Gantry Framework

Open templateDetails.xml and scroll down to the "positions" tag where the default Gantry positions are listed. Under here we will need to add our positions as in the example below:

 <position id="example" name="Example" max_positions="6">Example</position>
  

Next scroll down to the "fields" tag. This is where all the Gantry theme fields are defined including the widget positions. Scroll down then past the line which says

<field name="layoutstips" type="tips" tab="layouts" panel_position="right" show_label="false"/>
  
This is where we add our new position layout slider. We need to add the following xml block to make this appear in the Theme Manager:
  
<fields name="examplePosition" type="position" label="Label">
  <field name="layout" type="positions" default="6,6" label="">
    <schemas>1,2,3,4,5,6</schemas>
    <words>2,3,4,5,6,7,8,9,10</words>
  </field>
  <field name="showall" type="toggle" default="0" label="Force Positions"/>
  <field name="showmax" type="showmax" default="6" label="Position Count"/>
</fields>

  

  • name - name of position + Position
  • type - must always be "positions"
  • default - default layout for the widget any combination of 12 seperated by commas.
  • label - Label for this widget.
  • description - description of what this area is used for.

Step 4: Assign Widgets

The new position should now be available in the Appearance → Widgets and widgets can now be assigned. Once asssigned they will appear on your theme like any other Gantry widget.