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:
- 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!
- 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
- 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
- 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.
- If that fails Nextcellent starts over with singlepic.php:
- calls filter ngg_render_template once again
- Is there a file named …wp-content\themes\twentythirteen\nggallery\singlepic.php ?
- 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]
- Use a function on functions.php to add the ngg_render_template filter
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.