News Manager 2.5 next beta - Draft

If you're already using any NM 2.5 beta in a production site, read carefully. You have to do some changes before upgrading - I suggest you test it locally.

Since 2.5 beta 10:
- gsconfig settings $NMIMAGES, $NMTITLENOLINK and $NMREADMORE are no longer supported. Instead you use functions in component nm-init (and/or others). See "Defining layout settings"

- These gsconfig settings have not been changed:
$NMIMAGEINPUT, $NMIMAGEDIR and $NMARCHIVESBY

Layout options to override the plugin's defaults (post images, read more, remove link in title, etc.) now have to be set using GetSimple components (not in gsconfig as in previous beta versions). You have to create those you need in Theme -> Components. All are optional, you only have to create those you need to override the default setup.

Basically you have to create:

  • a component with name nm-init for your general/default layout settings
  • optionally some other components like nm-top-single, nm-top-archive, nm-top-tag, ... to define specific settings for full/single post pages, archives pages, tag pages, ...

Defining layout settings

The following tags/functions can be used in those components (usually in nm-init, and/or nm-top-single...) to define the layout of post(s).

They must be enclosed between <?php and ?> tags.

In most functions the second parameter can be true (default) or false, but you can use 1 or 0 instead.

Title link

Disable link to post in title (by default it is enabled):
nm_set_option('titlelink',false);

"Go back..." link

Disable:
nm_set_option('gobacklink',false);

Link to news index page (no javacript):
nm_set_option('gobacklink','main');

Excerpts

Enable excerpt:
nm_set_option('excerpt');

Disable excerpt (show full content):
nm_set_option('excerpt',false);

Show "read more" link after the excerpt (default is false):
nm_set_option('excerpt','readmore');

Show "read more" link after the excerpt in all posts (even short ones):
nm_set_option('excerpt','forcereadmore');

Images

(They are enabled by default)

Show post images:
nm_enable_images();

Do not show post images:
nm_disable_images();

Define image size:
nm_set_image_size(100,100);

Same but with cropped images:
nm_set_image_size(100,100,true);

Insert alt attribute (with post title) in <img> tags:
nm_set_image_option('alt');

Insert title attribute (with post title) in <img> tags:
nm_set_image_option('title');

Link images to posts:
nm_set_image_option('link');

Allow external images:
nm_set_image_option('external');

Default image for posts with no image (if not defined, no image is shown):
nm_set_image_option('default','image.jpg');

Layout blocks (components)

The plugin loads the following GS components (if they exist):

- Before the news/post content:

  • nm-init (loaded in all news pages) <-- use it for your default settings
  • nm-top-pagetype (pagetype can be single, tag, archive or search); if it doesn't exist, the default nm-top component is loaded.

- After the news/post content:

  • nm-bottom-pagetype (pagetype can be single, tag, archive or search); if it doesn't exist, nm-bottom is loaded
  • nm-end (for all news pages)


For example, if we're on a single/full post page the following components will be executed, in this order:

  • nm-init
  • nm-top-single / nm-top
  • ... post content ...
  • nm-bottom-single / nm-bottom
  • nm-end

You can also insert any html/PHP code you wish (e.g. some header, footer, banner...) in those components.

You would normally only create nm-init, unless you want to define specific settings (or code) for some news page type (e.g. nm-top-single for single/full post pages).

Redefining front-end texts/language strings:

You can change the default texts for "Published on", "Previous posts", etc. in your nm- components (normally you'll want to do it in nm-init), like:

<?php nm_set_text('PUBLISHED', 'Posted on: '); ?>
<?php nm_set_text('READ_MORE', 'Continue reading...'); ?>
... etc.

New: conditionals

You can use the following conditional functions in any component or template file:

  • nm_is_single()
  • nm_is_main()
  • nm_is_tag()
  • nm_is_archive()
  • nm_is_search()

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

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