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):
nm_custom_list_recent('
<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):
nm_custom_display_recent('
<div class="my_recent_{{ post_number }}">
<h4><a href="{{ post_link }}">{{ post_title }}</a></h4>
<span class="my_excerpt">{{ post_excerpt }}</span>
</div>
');
// 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_recent
, but with randomly selected postsAvailable tokens/placeholders:
You can use the following keys/variables in the html string. They will be replaced by the corresponding values for each post:
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_date('%d/%m/%Y');
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.
Example:
nm_set_custom_excerpt(120);
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.
Example:
nm_set_custom_maxposts(5);
nm_set_custom_offset(3);
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
<?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"