Делаем теги глобальными
Решение, которое поможет вывести разные данные тегов, которые привязаны к определенному TPL файлу в другом.
Установка:
1. Открыть engine/classes/templates.class.php и найти:
class dle_template {
Добавить ниже:
var $transfer = array ();
Найти далее:
function get_real_time() {
Добавить выше:
/* Глобализация данных */
function transfer_result($matches=array()){
$index = $matches[2];
$itsdata = $matches[3];
$this->transfer[$index] = $itsdata;
}
Найти далее:
if( isset( $this->result[$tpl] ) ) $this->result[$tpl] .= $this->copy_template;
Добавить выше:
/* Глобализация данных */
if (strpos ($this->template, "[transfer=" ) !== false) {
preg_replace_callback( "#\\[(transfer)=(.+?)\\](.*?)\\[/transfer\\]#is",array( &$this, 'transfer_result'), $this->copy_template);
foreach($this->transfer as $index => $itsdata) {
$this->result['transfer'][$index][] = $itsdata;
}
}
$this->copy_template = preg_replace ( "#\\[(transfer)=(.+?)\\](.*?)\\[/transfer\\]#is", "", $this->copy_template);
2. Открыть engine/classes/parse.class.php и найти:
$source = str_ireplace( "{custom",
Добавить ниже:
$source = str_ireplace( "{transfer", "{transfer", $source );
3. Открыть engine/modules/main.php и найти:
echo $tpl->result['main'];
Добавить выше:
/* Глобализация данных by rocksmart */
if( count($tpl->result['transfer']) > 0 ) {
foreach($tpl->result['transfer'] as $index => $itsdata) {
$tpl->result['main'] = str_replace ( '{transfer_' . $index . '}', implode($itsdata), $tpl->result['main'] );
}
}
$tpl->result['main'] = preg_replace( "#\\{transfer_(.+?)\\}#i", "", $tpl->result['main']);
Готово!
Пример использования:
[transfer=Уникальный идентификатор]какой либо текст с тегами соответствующими данному шаблону[/transfer]
Например для использования тега:
{title}
из шаблона fullstory.tpl в шаблоне main.tpl, следует в нужное место шаблона fullstory.tpl добавить:
[transfer=fulltitle]{title}[/transfer]
А в шаблоне main.tpl, где следует вывести название новости, следует добавить это:
{transfer_fulltitle}
• Автор: rocksmart
• Модификация: PunPun
• Источник
Посетители, находящиеся в группе Гость, не могут оставлять комментарии к данной публикации.