singlepic template parameter explained

Wikis > NextCellent Plugin > Shortcodes > The singlepic Shortcode > singlepic template parameter explained

Note: the contents of this page have moved and changed: new page.

The template parameter and the template inner working.

Let’s say we want to display an image like

[ singlepic id=9 ]

The singlepic shortcode always uses a template. By default the template is  singlepic.php and it’s located on the view folder on Nextcellent plugin view folder (usually would be something like wp-content\plugins\nextcellent-gallery\view\singlepic.php )

Let’s change the shortcode to

[ singlepic id=9 template=mytemplate]

In this case, Nextcellent will try to locate a template replacing the default one using the following logic:

  1. Check the filter ngg_render_template . If this filter returns a valid file, NextCellent will include this template. The filter ngg_render_template is a chance to store a template in any place you want, with any name, so this filter is a powerful one!
  2. If there is no filter, Nextcellent will start locating the current theme’s path. Let’s say your active theme is located on wp-content\themes\twentythirteen
  3. After that, Nextcellent will try to find a template named singlepic-mytemplate.php on the current theme under the nggallery folder. In the example, that would be on
  4. If that fails, NextCellent will try to load the singlepic-mytemplate.php under the view folder on the NextCellent plugin, this is the place where singlepic.php is usually located.
  5. If that fails Nextcellent starts over with singlepic.php:
    1. calls filter ngg_render_template once again
    2. Is there a file named …wp-content\themes\twentythirteen\nggallery\singlepic.php ?
    3. It finally will default on the singlepic.php on the plugin view folder.

So Nextcellent make a great deal in order to give the web owner a chance to put its own template in the place he likes more.

If you want to customize the template we suggest:

  • Copy singlepic.php to [your-theme]\nggallery folder
  • rename it following the rule described for example singlepic-blue_bkg.php
  • Use the following shortcode [ singlepic id=9 template=blue_bkg]



Try to avoid changing the original singlepic.php or adding custom templates on plugins view folder even the plugin support it, since any plugin upgrade would erase all the changes made on that folder

Under the hood

Take a look of the code .  As you can see, Nextcellent uses an internal template system using custom objects to help rendering HTML code.