This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
ru:theme:template_code_snippets [2013/09/13 08:08] Arkady [Ссылки] |
ru:theme:template_code_snippets [2013/09/18 06:44] (current) Arkady [Страницы этой секции] |
||
---|---|---|---|
Line 3: | Line 3: | ||
==returnPageContent()== | ==returnPageContent()== | ||
<code><?php returnPageContent(); ?></code> | <code><?php returnPageContent(); ?></code> | ||
- | Since 3.1 this Caching/Indexing function can be used to check the page content (example: conditionals). | + | Применяется с версии 3.1 Эту кэш-функцию можно использовать для проверки контента страницы (пример: проверка условий). |
==global $content;== | ==global $content;== | ||
<code><?php global $content; ?></code> | <code><?php global $content; ?></code> | ||
- | Since 3.1. Similar to returnPageContent() this can be used to check the page content. | + | Применяется с версии 3.1 То же самое, что и returnPageContent(), используется для проверки контента страницы. |
- | ==output author== | + | ==значение поля author документа, страницы == |
<code><?php echo $data_index->author; ?></code> | <code><?php echo $data_index->author; ?></code> | ||
<code><?php getPageField(return_page_slug(),'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> | <code><?php echo stripslashes(html_entity_decode($data_index->author, ENT_QUOTES, 'UTF-8') ); ?></code> | ||
- | The last example is for output of Unicode characters. | + | Последний пример служит для вывода Unicode-символов. |
- | ==conditional by template== | + | ==проверка условия по имени файла шаблона== |
<code><?php if ($template_file == 'name-of-template.php') { | <code><?php if ($template_file == 'name-of-template.php') { | ||
...</code> | ...</code> | ||
- | If used in a component, first do: | + | Если код используется в теле компонента, то его нужно предварить следующей строкой: |
<code>global $template_file;</code> | <code>global $template_file;</code> | ||
- | ==conditional by page (slug)== | + | ==проверка условия по постоянной ссылке(slug) страницы== |
<code><?php if (return_page_slug() == 'contact') { | <code><?php if (return_page_slug() == 'contact') { | ||
...</code> | ...</code> | ||
- | ==template ready for but not requiring a plugin== | + | ==шаблон будет работать как с плагином, так и без него== |
- | If for example you want to make a template ready for the Custom Title plugin but to work normally without it: | + | Если вам нужно, чтобы ваш шаблон использовал плагин Custom Title, а в случае отсутствия плагина создавал бы заголовок (title) страницы встроенной функцией GetSimple, требуемого результат можно добиться следующим способом: |
<code><title> | <code><title> | ||
<?php if (function_exists('get_custom_title_tag')) | <?php if (function_exists('get_custom_title_tag')) | ||
Line 47: | Line 47: | ||
*[[ru:themes:creation|Создание тем]] | *[[ru:themes:creation|Создание тем]] | ||
*[[ru:themes:template_tags|Список тэгов шаблона]] | *[[ru:themes:template_tags|Список тэгов шаблона]] | ||
- | *[[ru:theme:template_code_snippets|Примеры кода]] | ||
*[[ru:themes:tips|Советы по разработке]] | *[[ru:themes:tips|Советы по разработке]] | ||
| |