Powered by MediaWiki
Personal tools

TemplateTags

From b2evolution manual

Jump to: navigation, search

This manual page is outdated. NEW PAGE: TemplateTags in b2evolution v5+.

This page describes the functions used within a skin template (v 2.x) in order to inject the dynamic data into your blog design. (For versions 1.x, please see Main.php_functions)

Below is a listing of available template tags linking to a more detailed explanation for each of them. You will find getting started instructions farther down on this page.

Contents

[edit] Available template tags


[edit] Includes

The skin_include() template tag will include another template. Many of these templates can take parameters too:

[edit] Other template functions you might encounter

[edit] 5 easy things you should know about PHP

Those "Template Tags" are basically PHP functions. Here are the 5 things you need to know about PHP in order to get around:

  • PHP stuff must be enclosed within something similar to an HTML tag starting with <?php and ending with ?>
  • If you want to put several PHP functions within the same <?php ?> bloc, you must separate them with a semi column ";"
  • Whenever PHP sees a double slask like this: // , the rest of the line is considered to be a comment
  • You can also have multiline comments by starting with /* and ending with */
  • When you want to insert some text as a parameter to a function, you must enclose it in single quotes like this 'text' or double quotes like this "text".

[edit] A sample template tag

This is the template tag that displays the date of a post: <source lang="php"> <?php

 $Item->issue_date( array(
     'before'      => '',
     'after'       => '',
   ) );

?> </source>

In the instance above, the template tag has 2 parameters 'before' and 'after'. The HTML snippets that have been specified there will be added before and after the date.

You generally don't have to pass any parameters at all if you don't want to. In this case, default parameters will be used. With no parameters, the template tag would look like this: <source lang="php"> <?php

 $Item->issue_date( array(
   ) );

?> </source> Or it could be trimmed down even further, like this: <source lang="php"> <?php

 $Item->issue_date();

?> </source>

On the contrary, you can also add parameters. For example, you could specify the date format to use, like this: <source lang="php"> <?php

 $Item->issue_date( array(
     'before'      => '',
     'after'       => '',
     'date_format' => 'Y-m-d',
   ) );

?> </source>