Follow

How to Customise the Flatplan

Customising the Flatplan

There are elements of the flatplan that you can customise in order to make the content easier to navigate.

Displaying a nice description of the nodes This will show a more user friendly name of the template, rather than the machine name. It will also show the amount of images related to a node.

// Include the nice name in the description, and the number of images in the node
function mymodule_pugpig_admin_description($node) {
  $type = $node->type;
  $known_types = array('theme_article', 'theme_cover', 'theme_contents');
  if (!in_array($type, $known_types)) return NULL;
 
  $nicename = node_type_get_name($type);
  $num_images = count(_pugpig_get_images($node));
  $description =   $nicename  . ($num_images > 0 ? ' (' . $num_images . ' image' . ($num_images > 1 ? 's' : '') . ')' : '');
  return $description; 
}

Styling the node titles In order to help differentiate between the types of article or levels of hierarchy in the flatplan you can style the titles. Read more about How to Configure a Page Hierarchy

function mymodule_pugpig_admin_title_style($node, $parent_node = NULL) {   
  if (mymodule_pugpig_page_level($node) == 1) {
    // Bold for the top level items
    return 'color: black; font-weight:bold;';
  } 
 
  if ($node->type == 'theme_cover')
    return 'color: #3333BB;';
  else if ($node->type == 'theme_contents')
    return 'color:  #0000EE;';  
}

Styling the section categories

  mymodule_pugpig_admin_category_style($node, $categories) {
  if (isset($categories[0]))
    $section = $categories[0];
  else
    $section = '';
 
  switch ($section) {
    default:
    case '':
    return "background-color: #ffffff;";
    break;
    case 'news':
    return "background-color: red; color: white;";
    break;
    case 'sport':
    return "background-color: blue; color: white;";
    break;
    case 'culture':
    return "background-color: green; color: white;";
    break;
  }
}

Adding items to the admin menu The admin menu is at the top right of the flatplan, these elements will be added to the 'actions' column on the far right. This is helpful if you have data that is related to each editions, at the edition level, rather than article level.

// Add an extra item to the admin menu
function mymodule_pugpig_edition_action_items($edition, $edition_tag) {   
 $actions =
        l(t('product xml'), 'editions/' . $edition_tag . '/data/project/data.xml' , array('attributes' => array('target'=>'_blank')) ) . '<br />';
  return $actions;
}

By default the plugin shows the 'title' field in the flatplan You can customise this if you would prefer to show the header or another field instead.

function mymodule_pugpig_admin_flatplan_title($node) {
    return pugpig_value($node, 'other_title');
} 
Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

Powered by Zendesk