User Tools

Site Tools


ru:theme:template_code_snippets

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
ru:theme:template_code_snippets [2013/09/13 08:05]
Arkady [Страницы этой секции]
ru:theme:template_code_snippets [2013/09/13 10:09]
vladislav [Примеры кода]
Line 1: Line 1:
 +====== Примеры кода ======
 +
 +==returnPageContent()==
 +<​code><?​php returnPageContent();​ ?></​code>​
 +Применяется с версии 3.1 this Caching/​Indexing function can be used to check the page content (example: conditionals). ​
 +
 +==global $content;​== ​
 +<​code><?​php global $content; ?></​code>​
 +Применяется с версии 3.1 Similar to returnPageContent() this can be used to check the page content. ​
 +
 +==output author== ​
 +<​code><?​php echo $data_index->​author;​ ?></​code>​
 +<​code><?​php getPageField(return_page_slug(),'​author'​);​ ?></​code>​
 +<​code><?​php echo stripslashes(html_entity_decode($data_index->​author,​ ENT_QUOTES, '​UTF-8'​) ); ?></​code>​
 +Последний пример служит для вывода Unicode-символов. ​
 +
 +==conditional by template==
 +<​code><?​php if ($template_file == '​name-of-template.php'​) {
 +...</​code>​
 +Если код используется в теле компонента,​ то его нужно предварить следующей строкой:​
 +<​code>​global $template_file;</​code>​
 +
 +==conditional by page (slug)==
 +<​code><?​php if (return_page_slug() == '​contact'​) {
 +...</​code>​
 +
 +==шаблон будет работать как с плагином,​ так и без него==
 +Если вам нужно, чтобы ваш шаблон использовал плагин Custom Title, а в случае отсутствия плагина создавал бы заголовок (title) страницы встроенной функцией GetSimple, требуемого результат можно добиться следующим способом:​
 +<​code><​title>​
 + <?php if (function_exists('​get_custom_title_tag'​))
 + {echo(get_custom_title_tag());​}
 + else { get_page_clean_title();​ }  ?>
 +</​title></​code>​
 +
 +
 +
 +
 +
 ====== Ссылки ====== ====== Ссылки ======
  
ru/theme/template_code_snippets.txt · Last modified: 2013/09/18 06:44 by Arkady