Follow

How to Configure a Page Hierarchy

Configure a Page Hierarchy

The plugin supports the ability for pages to sit at different levels. This level is sent as part of the content feed and could be used, although it is not used by the default clients. The server uses the level for the following:

 

Module Hooks

By default, every item has a level of 1. In the example below, the example below will put all items of type “index” or “cover” at level 1, and all others at level 2. This function needs to go into your Pugpig extension module.

// Cover and Index at level 1. Everything else at 2
function MYMODULE_pugpig_page_level($node) {
   if ($node->type == 'index' || $node->type == 'cover') return 1;
   return 2;
}
 

Iterating over child pages

If you wish to implement section index pages, for example, it is useful to be able to get all child pages and iterate over these. You can do this using the function _pugpig_get_children_from_level($node). For example:

  // Get index page children
  $children_from_level = _pugpig_get_children_from_level($node);
  if (count($children_from_level) > 0) {
    foreach($children_from_level as $nid) {
      $node = node_load($nid);
      // Display information about the child node here
      // .
      // .     
    } 
  }

Alternatively, there is a helper function which will return the entire edition structure given the edition -pugpig_get_nested_section_array($edition). This implements the same logic as the clients implement for creating the native table of contents. More information is available at How to Create Your Own Templates

pugpig_get_nested_section_array

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

Powered by Zendesk