Follow

How to Customise the Flatplan

The flatplan is the panel in the 'Edit Edition Item' view on the CMS that displays the contents of an edition, i.e., its pages and posts.

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

Sorting You can provide a custom sort function for ordering items in the flatplan. The example below assumes some function exists to get a page number from the custom meta data for a post

add_filter('pugpig_custom_flatplan_sort','your_extension_custom_flatplan_sort',10,3);
function your_extension_custom_flatplan_sort($ret, $a, $b) {
  // Sort within a sections only.
  // If you want to sort the whole edition, either remove the section
  // order from the pugpig setting, or take out the $ret==0 check
  if ($ret == 0) {
    $page_a = your_extension_get_page_for_sort($a);
    $page_b = your_extension_get_page_for_sort($b);
    if ($page_a == $page_b) {
      $title_a = $a->post_title;
      $title_b = $b->post_title;
 
      return strnatcmp($title_a, $title_b);
    }
    return ($page_a < $page_b) ? -1 : 1;
  }
}

Styling. Change the styles (colours, fonts, etc)

add_filter('pugpig_flatplan_style', 'your_extension_pugpig_flatplan_style', 10, 2);
function your_extension_pugpig_flatplan_style($output, $post) {
  if ($post->post_type != PUGPIG_AD_BUNDLE_POST_TYPE) return $output;
  return $output . "color: green;";
}

Summary Change the post summary

add_filter('pugpig_feed_post_summary', 'your_extension_feed_post_summary', 10, 2);
function your_extension_feed_post_summary($summary, $post) {
  $length = strlen($summary);
  $short_summary = substr($summary, 0, 40);
  if ($length > 40) {
    $short_summary .= " [...]";
  }
  return $short_summary;
}

Description. Change the description text shown

add_filter('pugpig_flatplan_description', 'your_extension_pugpig_flatplan_description', 10, 2);
function your_extension_pugpig_flatplan_description($output, $post) {
 
  $author_name = get_post_meta( $post->ID, 'author', true );
 
  if (!empty($author_name))  {
    $output .= " [By $author_name]";
  };
 
  return $output;
}
Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

Powered by Zendesk