$user_short_tpl = array( 'default' => 'shortstory.tpl', //дефолтный шаблон 'list' => 'shortstory_list.tpl', // шаблон списком 'icons' => 'shortstory_icons.tpl' // шаблон картинки );
$change_template = false; $allt = array(); $user_tpl_tmp = isset($_COOKIE['short_template']) ? totranslit($_COOKIE['short_template']) : 'default'; if( isset($config['change_template']) AND $config['change_template'] != '' ) { $user_short_tpl_tmp = explode(',', $config['change_template']); if( count($user_short_tpl_tmp) > 1 ) $change_template = true; foreach($user_short_tpl_tmp as $val) { $val = explode('|',$val); $allt[] = $val[0]; } } if( !in_array( $user_tpl_tmp, $allt ) ) $user_tpl_tmp = 'default'; $user_tpl = ($user_tpl_tmp == 'default' OR !$change_template) ? 'shortstory.tpl' : 'shortstory_'.$user_tpl_tmp.'.tpl'; if( $view_template != "rss" ) { if( $category_id and $cat_info[$category_id]['short_tpl'] != '' ) $tpl->load_template( $cat_info[$category_id]['short_tpl'] . '.tpl' ); else $tpl->load_template( $user_tpl ); }
$change_template = $change_template ? $change_template : false; if( isset($config['change_template']) AND $config['change_template'] != '' ) { $user_short_tpl = array(); $user_short_tpl_tmp = explode(',', $config['change_template']); if( $change_template ) { foreach( $user_short_tpl_tmp as $val ) { $val = explode('|', $val); $user_short_tpl[] = array('template' => $val[0], 'name' => htmlspecialchars_decode($val[1])); } } } else { $user_short_tpl = array( array('template' => 'default', 'name' => 'Стандарт'), array('template' => 'list', 'name' => 'Список'), array('template' => 'icons', 'name' => 'Иконки') ); } if( $change_template ) { $sortn_arr = array(); foreach( $user_short_tpl as $val ) { if( is_array($val) ) { $active_template = ' '; if( $user_tpl_tmp == $val['template'] ) $active_template = ' class="current" '; $sortn_arr[] = '<a href="#"'.$active_template.'data-template="'.$val['template'].'">'.$val['name'].'</a>'; } } $sortn_arr = implode(' | ', $sortn_arr); $sortn = <<<HTML <div class="sortn dpad"> <div class="sortn"> <div class="templater">Режим просмотра: {$sortn_arr}</div> </div> </div> HTML; $tpl->set ( '{sortn}', $sortn); } else $tpl->set ( '{sortn}', '');
if(preg_match("#min=['\"](\d+)['\"]#i",$tpl_list[1],$mint)) $min = $mint[1];
while($row = $db->get_row()){ $tags[$row['tag']] = $row['count']; $counts[] = $row['count']; }
while($row = $db->get_row()){ if( $row['count'] >= $min ) { $tags[$row['tag']] = $row['count']; $counts[] = $row['count']; } }
trim($_COOKIE['short_template'])
.class {display:none;} .class:first-child {display:inline-block;}
<?xml version="1.0" encoding="utf-8"?> <dleplugin> <name>Change shortstory</name> <description>В шаблоне main.tpl и других подключенных в нём в удобном месте используйте {sortn} Добавление и изменение html разметки осуществляется в разделе "Действия в файлах" в правках над файлом "engine/modules/main.php"</description> <icon></icon> <version></version> <dleversion>13</dleversion> <versioncompare>greater</versioncompare> <mysqlinstall><![CDATA[]]></mysqlinstall> <mysqlupgrade><![CDATA[]]></mysqlupgrade> <mysqlenable><![CDATA[]]></mysqlenable> <mysqldisable><![CDATA[]]></mysqldisable> <mysqldelete><![CDATA[]]></mysqldelete> <file name="engine/modules/show.short.php"> <operation action="replace"> <searchcode><![CDATA[ if( $view_template != "rss" ) { if( $category_id and $cat_info[$category_id]['short_tpl'] != '' ) $tpl->load_template( $cat_info[$category_id]['short_tpl'] . '.tpl' ); else $tpl->load_template( 'shortstory.tpl' ); }]]></searchcode> <replacecode><![CDATA[$change_template = true; if( isset($config['change_template']) AND $config['change_template'] != '' ) { $user_short_tpl_tmp = explode(',', $config['change_template']); if( count($user_short_tpl_tmp) <= 1 ) $change_template = false; } $user_tpl = isset($_COOKIE['short_template']) ? trim($_COOKIE['short_template']) : 'default'; $user_tpl = ($user_tpl == 'default' OR !$change_template) ? 'shortstory.tpl' : 'shortstory_'.$user_tpl.'.tpl'; if( $view_template != "rss" ) { if( $category_id and $cat_info[$category_id]['short_tpl'] != '' ) $tpl->load_template( $cat_info[$category_id]['short_tpl'] . '.tpl' ); else $tpl->load_template( $user_tpl ); }]]></replacecode> </operation> <operation action="after"> <searchcode><![CDATA[$db->free( $sql_result );]]></searchcode> <replacecode><![CDATA[$onload_scripts[] = <<<HTML $(".templater a[data-template]").click(function(){ if($(this).hasClass('current')) return false; $(this).addClass('current').siblings().removeClass('current'); $(".templtes").removeClass('current'); $(".template-"+$(this).data('template')).addClass('current'); Cookie.create('short_template', $(this).data('template'), { expires: 8760, path: '/' }); window.location.href=location.href; return false; }); HTML;]]></replacecode> </operation> </file> <file name="engine/modules/main.php"> <operation action="after"> <searchcode><![CDATA[$tpl->set ( '{speedbar}', $tpl->result['speedbar'] );]]></searchcode> <replacecode><![CDATA[$change_template = true; if( isset($config['change_template']) AND $config['change_template'] != '' ) { $user_short_tpl = array(); $user_short_tpl_tmp = explode(',', $config['change_template']); if( count($user_short_tpl_tmp) <= 1 ) $change_template = false; if( $change_template ) { foreach($user_short_tpl_tmp as $val) { $val = explode('|', $val); $user_short_tpl[] = array('template' => $val[0], 'name' => htmlspecialchars_decode($val[1])); } } } else { $user_short_tpl = array( array('template' => 'default', 'name' => 'Стандарт'), array('template' => 'list', 'name' => 'Список'), array('template' => 'icons', 'name' => 'Иконки') ); } if( $change_template ) { $sortn_arr = array(); $user_tpl = isset($_COOKIE['short_template']) ? trim($_COOKIE['short_template']) : 'default'; foreach($user_short_tpl as $val){ if( is_array($val) ) { $active_template = ' '; if($user_tpl == $val['template']) $active_template = ' class="current" '; $sortn_arr[] = '<a href="#"'.$active_template.'data-template="'.$val['template'].'">'.$val['name'].'</a>'; } } $sortn_arr = implode(' | ', $sortn_arr); $sortn = <<<HTML <div class="sortn dpad"> <div class="sortn"> <div class="templater">Режим просмотра: {$sortn_arr}</div> </div> </div> HTML; $tpl->set ( '{sortn}', $sortn); } else $tpl->set ( '{sortn}', '');]]></replacecode> </operation> </file> <file name="engine/inc/options.php"> <operation action="after"> <searchcode><![CDATA[showRow( $lang['opt_sys_biw'], $lang['opt_sys_biwd'], makeCheckBox( "save_con[bbimages_in_wysiwyg]", "{$config['bbimages_in_wysiwyg']}" ) );]]></searchcode> <replacecode><![CDATA[showRow( $lang['change_template'], $lang['change_template_2'], "<textarea class=\"classic\" style=\"width:100%;height:150px;\" name=\"save_con[change_template]\">{$config['change_template']}</textarea>" );]]></replacecode> </operation> <operation action="before"> <searchcode><![CDATA[$save_con['offline_reason'] = trim(strip_tags(stripslashes( $save_con['offline_reason'] )));]]></searchcode> <replacecode><![CDATA[$save_con['change_template'] = trim(stripslashes( $save_con['change_template'] )); $save_con['change_template'] = htmlspecialchars( $save_con['change_template'], ENT_QUOTES, $config['charset']);]]></replacecode> </operation> <operation action="replace"> <searchcode><![CDATA[if( $name != "offline_reason" ) {]]></searchcode> <replacecode><![CDATA[if( $name != "offline_reason" AND $name != "change_template" ) {]]></replacecode> </operation> </file> <file name="language/Russian/adminpanel.lng"> <operation action="after"> <searchcode><![CDATA['wysiwyg_language' => "ru",]]></searchcode> <replacecode><![CDATA['change_template' => "Список шаблонов", 'change_template_2' => "Перечислите шаблоны для смены<br />Пример: <strong>default</strong>-<strong>Стандарт</strong> | <strong>list</strong>-<strong>Список</strong> | <strong>icons</strong>-<strong>Иконки</strong><br /><br />Префикс шаблона - Текст или картинка<br /> - default = shortstory.tpl<br /> - list = shortstory_<strong>list</strong>.tpl<br />Для отключения смены оставьте один шаблон. Пустое поле задействует стандартный набор смены шаблонов.",]]></replacecode> </operation> </file> </dleplugin>
Рейтинг: <b>[xfvalue_mrating]</b> из 10
require_once ENGINE_DIR . '/mods/miniposter/loader.php'; Miniposter::getInstance()->build($tpl->result['content']);
<div class="short nl nl2"> <div class="short-in"> <a class="short-poster img-box with-mask" href="{full-link}"> [