Special plugin markup tags for templates

gdT3 templates system used in GD Products Center Pro relies on mix of HTML, CSS, PHP and special markup template tags to add plugin specific data and features into the rendered output. There are many tags available for this purpose, and this tutorial will show how to use them.

Before we go on, there is a basic introduction tutorial on the structure of the template tag. This tutorial explains the tag elements and how you can use them: Structure for special templates tags

Main thing to know about the rendering in the GD Products Center, is that there are 4 types to templates available. Some of the templates tags can be used with all types of templates, but some tags can be used only with some templates.

Here are some previous tutorials on templates for this plugin: gdT3: Rendering Templates System – Basics

In the documentation for each of the template tags, you will find all the information you need, including restrictions for the templates where tags can be used: not all tags work with every type of template.

Templates for archives are first thing we need to discuss. Templates rendering engine doesn’t have own loops system, so if you need to display loop of data (WordPress loop, for instance), you need to implement it on your own. More important than that: if you try too use tags in the loop they will be rendered regardless of the loop. So, if you need to loop something, you need one more template. Basically, best example is this:

[php]<div>
<?php
if (have_posts()) :
while (have_posts()) :
the_post();
global $post;

gdpc_render_single_inside("simple-list", $post, true, false);
endwhile;
gdpc_render_pager();
else :
_e("No results found.", "gd-products-center");
endif;
?>
</div>[/php]

This is a loop from archive.normal-list.inc template. As you can see, if you need to display element inside the loop to support templates tags, you need to run rendering with the template you want to render for single product. Basically, rendering process runs like this:

  1. plugin takes template to render, and prepares the render object
  2. plugin parses the template and replaces all the special templates tags with their value
  3. resulting code is than evaluated so that PHP code in the template is executed

Point of this is that the loop we have on this page will be executed after the templates tag are parsed and replaced. That’s why we need to render loop content for products separately.

Getting back to the templates tags, GD Products Center implements many tags to display product properties, taxonomies terms, filter elements, product information. Plugin also uses special type of templates tags that produce no output, that are called directives and are used to control the data preparation before the rendering. Typically, they are listed on top of the template. Directives are also listed in the documentation for the plugin.

This tutorial doesn’t list available tags. To see all of them, you can check out the documentation for this plugin and get details on settings, modes and example of use: Template tags archive for GD Products Center

Some of the tags are included with the base gdT3 rendering library so that all plugins using gdT3 will have access to them. They are listed in the library documentation: Basic template tags archive for gdT3

Comments

Leave a Reply