User Tools

Site Tools


theme:template_code_snippets

This is an old revision of the document!


Short pieces of code to use in Template-files (from the Forum).

Template Code Snippets

returnPageContent()

<?php returnPageContent(); ?>

Since 3.1 this Caching/Indexing function can be used to check the page content (example: conditionals).

global $content;

<?php global $content; ?>

Since 3.1. Similar to returnPageContent() this can be used to check the page content.

output author

<?php echo $data_index->author; ?>
<?php getPageField(return_page_slug(),'author'); ?>
<?php echo stripslashes(html_entity_decode($data_index->author, ENT_QUOTES, 'UTF-8') ); ?>

The last example is for output of Unicode characters.

conditional by template

<?php if ($template_file == 'name-of-template.php') {
...

If used in a component, first do:

global $template_file;

conditional by page (slug)

<?php if (return_page_slug() == 'contact') {
...
theme/template_code_snippets.1351698868.txt.gz · Last modified: 2013/04/19 14:57 (external edit)