• DONATE to NULLED!
    Форуму и его команде можно помочь, мотивировать модераторов разделов.
    Помогите модератору этого раздела killoff лично.

Помощь Разные шаблоны для кратких новостей???

palec

Профессор
Регистрация
6 Дек 2006
Сообщения
282
Реакции
49
Помогите не могу не как разобраца... и так DLE 9.7 в админке для одной категории поставил свой шаблон для краткой новости, но этот шаблон отображается только в конкретной категории... нужно чтоб он так же отображался и на главной странице! Как это реализовать?
Нашел старый хак в интернете:
Код:
найти в engine/modules/show.short.php
while($row = $db->get_row($sql_result)){
 
ниже вставить
if ($cat_info[$row['category']]['short_tpl'] and $cat_info[$row['category']]['short_tpl'] != $bdssh)
{
$tpl->load_template($cat_info[$row['category']]['short_tpl'].'.tpl');
$bdssh = $cat_info[$row['category']]['short_tpl'];
}

Проблема в том что после установки этого хака у всех новостей пропадает кнопка:
Код:
<span class="argmore"><a href="{full-link}"><b>Подробнее</b></a></span>

Кнопка подробнее убрана в шаблоне который нужно вывести на главную страницу. Надеюсь кто то сможет помочь!
 
попробуй такой код, у себя не проверял но должен работать.
Код:
Открываем engine/modules/show.short.php
 
    Находим:
    $news_found = FALSE;
    Ниже вставляем:
    $short_main = FALSE;
    Находим:
          else $tpl->load_template( 'shortstory.tpl' );
    Заменяем на:
            else
            {
                if ( $category_id ) $tpl->load_template( 'shortstory.tpl' );
                else
                {
                    $template = get_vars( 'template' );
 
                     
                    if ( ! $template )
                    {
                        $template = array ( );
                     
                        foreach( $cat_info as $key => $value )
                        {
                            if ( $cat_info[$key]['short_tpl'] != '' AND file_exists( $tpl->dir . DIRECTORY_SEPARATOR . $cat_info[$key]['short_tpl'] . '.tpl' ) )
                                $template[$key] = file_get_contents( $tpl->dir . DIRECTORY_SEPARATOR . $cat_info[$key]['short_tpl'] . '.tpl' );
                        }
                     
                        if ( file_exists( $tpl->dir . DIRECTORY_SEPARATOR . 'shortstory.tpl' ) ) $template[0] = file_get_contents( $tpl->dir . DIRECTORY_SEPARATOR . 'shortstory.tpl' );
                        else die( 'Не возможно загрузить shortstory.tpl' );
                     
                        set_vars( 'template', $template );
                    }
                 
                    $short_main = true;
                }
            }
    Находим:
            while ( $row = $db->get_row( $sql_result ) ) {
    Ниже вставляем:
            if ( $short_main )
            {
                if ( isset( $template[intval( $row['category'] )] ) ) $tpl->copy_template = $template[intval( $row['category'] )];
                else $tpl->copy_template = $template[0];
             
                if ( ! $xfound AND ( strpos( $tpl->copy_template, "[xfvalue_" ) !== false OR strpos( $tpl->copy_template, "[xfgiven_" ) !== false ) )
                {
                    $xfound = true;
                    $xfields = xfieldsload();
                }
            }
после проделанных действий кеш почисти.
 
Вариант работает но перестает работать теги: [not-group=5][/not-group], [aviable=cat][/aviable], [not-aviable=cat][/not-aviable]...

//Горбушка: Избыточное цитирование...
 
Вариант работает но перестает работать теги: [not-group=5][/not-group], [aviable=cat][/aviable], [not-aviable=cat][/not-aviable]...

после
$xfields = xfieldsload();
}

вставь
Код:
if (strpos ( $template, "[aviable=" ) !== false) {
            $template = preg_replace ( "#\\[aviable=(.+?)\\](.*?)\\[/aviable\\]#ies", "\$this->check_module('\\1', '\\2')", $template );
        }
       
        if (strpos ( $template, "[not-aviable=" ) !== false) {
            $template = preg_replace ( "#\\[not-aviable=(.+?)\\](.*?)\\[/not-aviable\\]#ies", "\$this->check_module('\\1', '\\2', false)", $template );
        }
 
        if (strpos ( $template, "[not-group=" ) !== false) {
            $template = preg_replace ( "#\\[not-group=(.+?)\\](.*?)\\[/not-group\\]#ies", "\$this->check_group('\\1', '\\2', false)", $template );
        }
       
        if (strpos ( $template, "[group=" ) !== false) {
            $template = preg_replace ( "#\\[group=(.+?)\\](.*?)\\[/group\\]#ies", "\$this->check_group('\\1', '\\2')", $template );
        }
 
        if (strpos ( $template, "[page-count=" ) !== false) {
            $template = preg_replace ( "#\\[page-count=(.+?)\\](.*?)\\[/page-count\\]#ies", "\$this->check_page('\\1', '\\2')", $template );
        }
 
        if (strpos ( $template, "[not-page-count=" ) !== false) {
            $template = preg_replace ( "#\\[not-page-count=(.+?)\\](.*?)\\[/not-page-count\\]#ies", "\$this->check_page('\\1', '\\2', false)", $template );
        }
 
        if (strpos ( $template, "[tags=" ) !== false) {
            $template = preg_replace ( "#\\[tags=(.+?)\\](.*?)\\[/tags\\]#ies", "\$this->check_tag('\\1', '\\2', 'tags')", $template );
        }
 
 
        if (strpos ( $template, "[not-tags=" ) !== false) {
            $template = preg_replace ( "#\\[not-tags=(.+?)\\](.*?)\\[/not-tags\\]#ies", "\$this->check_tag('\\1', '\\2', 'tags', false)", $template );
        }
 
        if (strpos ( $template, "[news=" ) !== false) {
            $template = preg_replace ( "#\\[news=(.+?)\\](.*?)\\[/news\\]#ies", "\$this->check_tag('\\1', '\\2', 'news')", $template );
        }
 
 
        if (strpos ( $template, "[not-news=" ) !== false) {
            $template = preg_replace ( "#\\[not-news=(.+?)\\](.*?)\\[/not-news\\]#ies", "\$this->check_tag('\\1', '\\2', 'news', false)", $template );
        }
 
Еще как вариант, стандартными способами в шаблоне shortstory.tpl вывести нужные шаблоны кратких новостей и ограничить их тегами шаблона: (для пары каталогов делал).
[catlist=1,2] шаблон 1 [/catlist]
[catlist=3,4] шаблон 2 [/catlist]

или

[not-catlist=1,2] шаблон 1 [/catlist]
[not-catlist=3,4] шаблон 2 [/catlist]
 
Собственно сабж, дабы не плодить темы спрошу здесь.
Dle 10/3 вывод shortstory на главной с разными шаблонами. В принципе тег {custom} мог бы спасти ситуацию, если бы не одно но, нарушает сортировку вывода новостей из разных категорий к примеру:
{custom category="1" template="shab-1" aviable="main" navigation="no" from="0" limit="10" fixed="yes" order="date" cache="yes"}
{custom category="2" template="shab-2" aviable="main" navigation="no" from="0" limit="10" fixed="yes" order="date" cache="yes"}
Вроде бы все ок, но мне нужно что бы все новости на главной сортировались по дате, а так получается новости из категории "1" всегда будут выше категории "2" хоть и поздней дате.
Был бы кстати хак ShortMain, но я так понимаю он под версии dle ниже, код в хаке и dle 10/3 отличается.
Есть какие то еще варианты решения ?
 
сам и отвечу
Методом тыка и поиска вот что нашел:
  1. Открываем engine/modules/show.short.php
    • Находим:
      $news_found = FALSE;
    • Ниже вставляем:
      $short_main = FALSE;
    • Находим:
      else $tpl->load_template( 'shortstory.tpl' );
    • Заменяем на:
      else
      {
      if ( $category_id ) $tpl->load_template( 'shortstory.tpl' );
      else
      {
      $template = get_vars( 'template' );


      if ( ! $template )
      {
      $template = array ( );

      foreach( $cat_info as $key => $value )
      {
      if ( $cat_info[$key]['short_tpl'] != '' AND file_exists( $tpl->dir . DIRECTORY_SEPARATOR . $cat_info[$key]['short_tpl'] . '.tpl' ) )
      $template[$key] = file_get_contents( $tpl->dir . DIRECTORY_SEPARATOR . $cat_info[$key]['short_tpl'] . '.tpl' );
      }

      if ( file_exists( $tpl->dir . DIRECTORY_SEPARATOR . 'shortstory.tpl' ) ) $template[0] = file_get_contents( $tpl->dir . DIRECTORY_SEPARATOR . 'shortstory.tpl' );
      else die( 'Не возможно загрузить shortstory.tpl' );

      set_vars( 'template', $template );
      }

      $short_main = true;
      }
      }
    • Находим:
      while ( $row = $db->get_row( $sql_result ) ) {
    • Ниже вставляем:
      if ( $short_main )
      {
      if ( isset( $template[intval( $row['category'] )] ) ) $tpl->copy_template = $template[intval( $row['category'] )];
      else $tpl->copy_template = $template[0];

      if ( ! $xfound AND ( strpos( $tpl->copy_template, "[xfvalue_" ) !== false OR strpos( $tpl->copy_template, "[xfgiven_" ) !== false ) )
      {
      $xfound = true;
      $xfields = xfieldsload();
      }
      }

После редактирование или создания категорий необходимо очистить кэш сайта, чтобы было произведено повторное кэшеирование шаблонов.

Пы.Сы. Куда ГорбушКу дели ?77 ГорбушКа помог бы (
 
Последнее редактирование модератором:
Назад
Сверху