News Manager Addons (plugin)

The News Manager Addons plugin provides several additional functions to extend the News Manager plugin, so that you can customize its output (typically the sidebar latest posts, or front page featured posts,...).

Requirements: News Manager plugin 2.2.x or higher

Download: Extend / GitHub page (direct download: news_manager_addons.php)

Installation: upload/copy the file to your site's plugins folder. Make sure it is activated in GetSimple's admin panel.

Custom sidebar functions/template tags:

  • nm_custom_list_recent($template)
    It works like News Manager's nm_list_recent function, but that you can customize the display of each <li> element. You can pass it a string (between quotes) that contains html code and some tokens.
    Usage (example):

      <a href="{{ post_link }}">{{ post_title }}</a><br />
      <em>{{ post_date }}</em><br />
      {{ post_excerpt }}
  • nm_custom_display_recent($template, $tag)
    Same as nm_custom_list_recent, but does not generate the <ul>...</ul> structure and items are not enclosed between <li> and </li> (so you can use div's or what you prefer). Optional second parameter to filter by a given tag.
    Usage (example):

       <div class="my_recent_{{ post_number }}">
          <h4><a href="{{ post_link }}">{{ post_title }}</a></h4>
          <span class="my_excerpt">{{ post_excerpt }}</span>
    // first post will be like: <div class="my_recent_1"> ...
  • nm_custom_display_future($template, $tag)
    Like nm_custom_display_recent, but for scheduled posts (with date in the future)

  • nm_custom_display_random($template, $tag)
    Like nm_custom_display_recent, but with randomly selected posts

Available tokens/placeholders:

You can use the following keys/variables in the html string. They will be replaced by the corresponding values for each post:

  • {{ post_link }} - absolute URL of post
  • {{ post_title }} - post title
  • {{ post_title_excerpt }} - post title excerpt (News Manager 3.0+)
  • {{ post_date }} - post date/time
  • {{ post_excerpt }} - post content excerpt
  • {{ post_content }} - post content (note: unfiltered)
  • {{ post_slug }} - post id (slug)
  • {{ post_number }} - number of post as displayed (0, 1, 2, ...)
  • {{ post_image }} - <img ...> tag for the post image (News Manager 3.0+)
  • {{ post_image_url }} - post image URL (News Manager 3.0+)
  • {{ post_author }} - author's display name (News Manager 3.2+)

Overriding default number of recent posts, excerpt length and date format:

The previous two functions use the defaults for number of posts, excerpt length (as defined in News Manager settings) and date format (defined in News Manager language file). You can change this default behaviour by using the following functions (that need to be inserted before the display functions)

  • nm_set_custom_date($dateformat)
    Sets the date/time format (strftime) to be used by display functions (nm_custom_list_recent, etc.), overriding the default format defined in the selected language.
    Usage - example:

  • nm_set_custom_excerpt($excerptlength)
    Sets the maximum excerpt length to be used by display functions (nm_custom_list_recent, etc.), overriding the value defined in News Manager settings.

  • nm_set_custom_title_excerpt($excerptlength, $ellipsis)
    Sets the maximum excerpt length and optional custom ellipsis ("...") to be used in post title excerpts Example:
    nm_set_custom_title_excerpt(30, " ...");

  • nm_set_custom_maxposts($maxposts)
    Sets the maximum number of posts to be shown when using display functions (nm_custom_list_recent, etc.), overriding the News Manager setting.

  • nm_set_custom_offset($offset)
    Usage - example:
    First, second and third posts will not be displayed, only the fourth and following.

Other display functions available:

  • nm_list_recent_with_date($dateformat, $before=false)
    Usage (examples):

    <?php nm_list_recent_with_date(); ?>  
    <?php nm_list_recent_with_date(' - %d/%m/%Y'); ?>  
    <?php nm_list_recent_with_date('%d/%m/%Y - ', true); ?> <-- date before the title
  • nm_list_recent_by_tag($tag, $max=0)
    Usage (examples):
    <?php nm_list_recent_by_tag('books'); ?> <-- latest posts with tag "books" (number as defined in News Manager settings) ?>  
    <?php nm_list_recent_by_tag('music', 4); ?> <-- latest 4 posts with tag "music"