Установка!
Открыть engine/classes/templates.class.php и найти:
$this->template = file_get_contents( $this->dir . "/" . $tpl_name );
После вставить:
if (strpos ( $this->template, "[season=" ) !== false) {
$this->template = preg_replace_callback ( "#[(season)=(.+?)](.*?)[/season]#is", array( &$this, 'check_season'), $this->template );
}
Добавить новую функцию в этом классе:
function check_season( $matches=array() ) {
global $_TIME;
$seasons = array(
'winter' => array(12,1,2),
'spring' => array(3,4,5),
'summer' => array(6,7,8),
'autumn' => array(9,10,11)
);
$month = date ( "n", $_TIME );
$season = $seasons[$matches[2]];
$block = $matches[3];
if( isset($seasons[$matches[2]]) ) {
if( (in_array($month,$seasons[$matches[2]])) ) return $block; else return '';
} else {
return $block;
}
}
В шаблоне использовать: [season=spring]весна[/season] [season=winter]зима[/season][season=summer]лето[/season]
[season=autumn]осень[/season]
Автор: rocksmart