User Tools

Site Tools


ru:theme:template_code_snippets

This is an old revision of the document!


Примеры кода

returnPageContent()
<?php returnPageContent(); ?>

Применяется с версии 3.1 this Caching/Indexing function can be used to check the page content (example: conditionals).

global $content;
<?php global $content; ?>

Применяется с версии 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') ); ?>

Последний пример служит для вывода Unicode-символов.

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') {
...
template ready for but not requiring a plugin

Допустим, вам нужно, чтобы ваш шаблон использовал плагин Custom Title, а в случае отсутствия плагина создавал бы заголовок (title) страницы встроенной функцией GetSimple, требуемого результат можно добиться следующим способом:

<title>
		<?php if (function_exists('get_custom_title_tag'))
		{echo(get_custom_title_tag());}
		else { get_page_clean_title(); }  ?>
</title>

Ссылки

На главную Содержание

Страницы этой секции

Темы

ru/theme/template_code_snippets.1379066738.txt.gz · Last modified: 2013/09/13 10:05 by vladislav