News Manager 3.0 - what's new

Main new features in News Manager after version 2.4.x are:

  • Post images supported (post thumbnails, featured images)
  • Optional Read more link
  • Optional disable link in post titles
  • "go back" link can be disabled (or link to main news page)
  • Optional yearly archives
  • Custom settings for more options, post layout customization, custom frontend strings, specific newspage-type settings...
  • Template tags, conditional functions
  • Optional post authors
  • Custom URL parameters/prefixes (experimental/advanced)

For more information, see the Documentation below.

Documentation

News Manager 3.0 new features

New settings and options

Normal settings

There are some new options available in the plugin's setting page.

  • Enable post images + some image options
  • Optional Read more link (automatic or forced)
  • Optional disable link to post in post titles
  • "go back" link can be disabled (or made to link to the main news page instead of taking the user to the previous page)
  • Optional yearly archives (instead of monthly)

Custom Settings (and custom texts)

New "Custom settings" input box in the backend settings

You can specify advanced options and customize text strings, date format, etc., this way:

  • One setting per line. Option name and value separated by one or more spaces. String values can be enclosed in single or double quotes
  • Most settings are enabled with value 1 and disabled with 0, though several accept other values, or some text
  • Page-specific settings: if prefixed by single, main, archive, tag or search, the setting will be applied only to that specific news page type (overriding defaults)
  • Empty lines and comments (any line beginning with # or //) are ignored.
  • If option name is all uppercase it will be treated as a text/string instead of as a setting (see Custom frontend strings)

Example (lines beginning with # are just comments):

# general:
imageTitle 1  
imageDefault my-default-image.jpg

# specific page-type settings
single imageSize 500,200,0
archive showImages 0

# texts
ELLIPSIS "... "  
READ_MORE "Continue reading"  
DATE_FORMAT "%d.%m.%Y" 

Here we enable the title attribute for all post images; set a default image (for posts without it); a different post image size for full/single post pages; images are disabled in archives. Also, some frontend texts ("...", "read more") and the date format are customized (overriding the language file defaults)

Available custom settings/options:

Posts layout

  • excerpt 0 = full post, 1 = excerpt (automatically generated, without html tags). Not applicable to single post pages

  • breakWords 1 = enable cutting off the last word in excerpts (like it was in versions 2.4.x and older), if you prefer it this way. (default 0, disabled)

  • readMore 1 = display "read more" link, a = always display it (default 0, no "read more" link)

  • more 1 = enable (default 0, disabled) If enabled (and it's not a single post page), post content will be cut off at <hr string (that is, <hr>, or <hr />, ...) If the string "<hr" is not found, the usual stripped excerpt or full content is shown (depending on FullText/Excerpt selection or excerpt custom setting)

  • markupTitle HTML tag to be used in post titles, e.g. h1 (default h3)

  • markupPost HTML tag to be used in post containers, e.g. article (default div)

  • tagSeparator character(s) to be displayed between tags if there are several, e.g. ", " (default: a blank ``)

  • showFields list of fields to be displayed separated by commas or spaces (default title,date,author,image,content,tags)

  • componentBottomPost lets you specify a GS component to be rendered in the bottom of the post, before its container's closing tag (div by default)

  • componentAfterPost lets you specify a GS component to be displayed after the post (outside the post container)

  • titleLink 1 = link to post in post titles, 0 = no link

  • goBackLink 0 = no link, 1 = back to previous page, main = main news page. Only applicable to single post pages.

  • excerptLength a number, or 0 for no post excerpt/content. Use to override defined settings. Lets you customize the excerpt length, overriding the one defined in NM settings. Can be used to e.g. have shorter excerpts in archives, etc.

  • showImages 1 = enable displaying post images, 0 = disable (default: selection in settings)

  • imageTitle 1 = insert title attribute in <img /> tag, 0 = don't insert it (default)

  • imageExternal allow displaying external post images: 1 = allow, 0 = disallow (default)

  • imageDefault string: filename of image to show for posts with no image defined

  • imageSizeAttr 1 = insert width and height attributes in <img /> tag, 0 =don't insert them (default)

  • imageClass string: Lets you set a custom class for post images. For example, if you use the Skeleton (or nickpack/Ribs) framework you can add class "scale-with-grid" to make post images responsive: imageClass scale-with-grid, or if you use Bootstrap you can add class "img-responsive" with imageClass img-responsive

  • imageSize Lets you customize width, height and cropping of post images overriding your normal settings. Parameters separated by commas and/or spaces; `` or full for original image. (it's just a shorthand for imagewidth, imageheight and imagecrop)
    For example, if you want full images in single post view, and cropped 90x90 images in archives:
    single imageSize full
    archive imageSize 90,90,1

  • imageWidth maximum width in pixels, 0 = full (default: selection in settings)

  • imageHeight maximum height in pixels, 0 = full (default: selection in settings)

  • imageCrop 1 = enable image cropping to fit dimensions, 0 = don't crop (default: selection in settings)

  • imageAlt 1 = enable img alt attribute with post title, 0 = disable (default: selection in settings)

  • imageLink 1 = make images link to posts, 0 = no links in images (default: selection in settings)

Page navigation

  • navOldNew 1 = enable "Older posts/Newer posts"-type navigation, 0 = disable (default)

  • navNumber 0 = disable numbered page navigation, 1 = enable (default)

  • navPrevNext 0 = disable prev/next links, 1 = enable (default), "a" = always show both (even on first and last pages - if not linked the text will have class="disabled")

  • showNav 0 = disable page navigation, 1 = enable (default)

(See also gsconfig.php setting NMFIRSTPAGE)

Post authors

  • showAuthor 1 = enable display authors in posts, 0 = disabled (default)

  • defaultAuthor a string, the name to display if the post has no author (and showauthor is enabled)

See also gsconfig.php settings required to enable this optional feature

Other custom settings

  • tagPagination enable tag page pagination like in the main news page. Can be enabled with tagpagination d (default, dynamic) or tagpagination f (fancy or folder-style, requires adding a rewriterule in .htaccess) (default 0, disabled)

  • templateFile select a different template file, overriding the one defined in the news page. For example if you want to use temp-post.php for your full posts, enter: single templateFile temp-post.php

  • titleTag update <title> tag (insert the post title before the page title, separated by a dash) Default is 1 (enabled), set to 0 if you have trouble with your setup

Custom/redefinable front-end texts/strings and date format

These are the frontend text strings you can redefine (and their default values in the English language file)

  • PUBLISHED "Published on"
  • AUTHOR "Author:"
  • TAGS "Tags"
  • ELLIPSIS " [...] "
  • READ_MORE "Read more"
  • GO_BACK "<< Go back to the previous page"
  • OLDER_POSTS "← Older Posts"
  • NEWER_POSTS "Newer Posts →"
  • SEARCH "Search"
  • FOUND "The following posts have been found:"
  • NOT_FOUND "Sorry, your search returned no hits."
  • NOT_EXIST "The requested post does not exist."
  • NO_POSTS "No posts have been found."
  • PREV_TEXT "<",
  • PREV_TITLE "Previous page",
  • NEXT_TEXT ">",
  • NEXT_TITLE "Next page",

Date format strings (strftime):

  • DATE_FORMAT "%b %e, %Y"
  • MONTHLY_FORMAT "%B %Y"
  • YEARLY_FORMAT "%Y"

gsconfig.php settings

There are several options that you cannot use in the admin settings, but have to be inserted in your GetSimple site's root gsconfig.php file.

Image input position

Lets you set up the post image input field/selector. Example:

define('NMIMAGEINPUT', 3);

Possible values:

  • 0 or FALSE : not visible
  • 1 : in Options, first field
  • 2 or TRUE : in Options, last field
  • 3 : directly visible above content
  • 4 : directly visible below content

Default image directory

Default subfolder (of data/uploads) for selecting post images

define('NMIMAGEDIR', 'imagefolder');

(so it will be YOURSITE/data/uploads/imagefolder)

Lowercase tags

Force usage of tags in lowercase:

define('NMLOWERCASETAGS', true);

Exclude posts from Sitemap

If you don't want posts to be included in sitemap.xml:

define('NMNOSITEMAP', true);

Enable post authors

Optional support for post authors. By default it is disabled. To enable storing usernames in post files you have to add this to your gsconfig.php:

define('NMSAVEAUTHOR', true);

To display authors in your site, use custom settings showauthor and/or defaultauthor (see above)

Custom URL parameters/prefixes (and page index)

You can redefine the post, page, tag and archive parameters used in NM URLs, via gsconfig settings NMPARAMPOST, NMPARAMPAGE, NMPARAMTAG and NMPARAMARCHIVE.

Example:

define('NMPARAMPOST', 'article');

A single post URL will end with ?article=this-is-a-title instead of ?post=this-is-a-title (or /article/this-is-a-title with NM fancy URLs enabled)

To make it work with NM fancy URLs you must edit your .htaccess file accordingly, for example:

RewriteRule ^newspage/article/([^/.]+)/?$ index.php?id=newspage&article=$1 [L]

Since 3.0 by default the first page index (URL) is 1, so the second page is page=2 (or page/2). If you prefer to start with 0 like in previous versions:

define('NMFIRSTPAGE', 0);

Single post URLs without prefix

You can have single post URLs without the /post/ prefix if using News Manager fancy URLs by using the NMNOPARAMPOST and editing your .htaccess file. Usage:

Add the gsconfig setting:

define('NMNOPARAMPOST',true);

And insert another News Manager-specific rewriterule in .htaccess, like (if your news page id is news):

RewriteRule ^news/([^/.]+)/?$ index.php?id=news&post=$1 [L]

Notes:

  • Only works for slugs that are not index
  • News page cannot have normal child pages

Frontend functions/template tags

Template tags

You can use these functions in your templates or components.

nm_post_slug()

echo/return current post slug.
nm_post_slug() echoes the post slug.
nm_post_slug(false) returns it

nm_post_url()

echo/return current post permalink.
nm_post_url() echoes the post permalink.
nm_post_url(false) returns it

nm_post_excerpt()

optional parameters: length, ellipsis; default as in settings)

Examples:

<?php nm_post_excerpt(); ?>

<?php nm_post_excerpt(100,'...'); ?>

<?php nm_post_excerpt(200) or get_page_excerpt(200); ?>

nm_post_image_url()

optional parameters: width, height, crop, default image

Examples:

<?php nm_post_image_url(); ?>

<?php nm_post_image_url(300,200,1); ?>

Conditional functions

nm_is_site()

returns true if current page is the news page

nm_is_home()

returns true if main news index page.

Example:

<?php if (nm_is_home()) {

// display or do something ...

} ?>

nm_is_main()

returns true if on the main news index page (including "older posts" pages)

nm_is_archive()

returns true if news archive page.

nm_is_search()

returns true if news search page.

nm_is_single()

returns true if single post page.

For example, if you want to show some text only in single/full post pages:

<?php if (nm_is_single()) { ?>
... your text/code ...
<?php } ?>

nm_is_tag()

returns true if we're on any tag page.

The function can be passed a parameter for a certain tag, for example nm_is_tag('books') would return true if we're in the tag page for books

nm_post_has_tag()

checks if current single post has any tag or a certain tag (passed as a parameter, e.g. nm_post_has_tag('software'))

nm_post_has_image()

returns true if current single post has an image.

Example:

<?php if (nm_post_has_image()) { ?>
  <img src="<?php nm_post_image_url(); ?>" />
<?php } ?>

New sidebar function

nm_tag_list()

displays a plain <ul> list. (No tag cloud, as opposed to nm_list_tags)

<?php nm_tag_list(); ?>