Не нравятся результаты поиска? Попробуйте другой поиск!
DLE FAQ » Все вопросы » Общие вопросы по PHP » Почему не работает rss канал сайта?

Почему не работает rss канал сайта?


     11.11.2014    rss    Общие вопросы по PHP, Хаки    3217

вопрос
Использовал хак для возможности использования разных шаблонов коротких новостей на главной. Для этого в /engine/moodules/show.short.php после
while($row = $db->get_row($sql_result)){

вставил
$bds_tpl = $cat_info[$row['category']]['short_tpl'] ? $cat_info[$row['category']]['short_tpl'] : 'shortstory';
if ($bds_tpl != $bdssh)
{
$tpl->load_template($bds_tpl.'.tpl');
$bdssh = $bds_tpl;
}


и после
$row['category'] = intval( $row['category'] );

вставил
$cat_idd = $row['category'];
if( isset( $view_template ) and $view_template == "rss" ) {
}
elseif( $category_id and $cat_info[$category_id]['short_tpl'] != '' ) $tpl->load_template( $cat_info[$category_id]['short_tpl'] . '.tpl' );
elseif( $cat_idd and $cat_info[$cat_idd]['short_tpl'] != '' ) $tpl->load_template( $cat_info[$cat_idd]['short_tpl'] . '.tpl' );
else $tpl->load_template( 'shortstory.tpl' );


С шаблонами все работает, но вот перестал работать rss сайта, при переходе сайт/rss.xml получаем сообщение Template not found: /templates/shortstory.tpl. Может кто-то поможет исправить этот косяк хака?

Ответил: ПафНутиЙ


последний кусок кода должен быть таким:
$cat_idd = $row['category'];
if( $category_id and $cat_info[$category_id]['short_tpl'] != '' ) {
    $tpl->load_template( $cat_info[$category_id]['short_tpl'] . '.tpl' );
} elseif( $cat_idd and $cat_info[$cat_idd]['short_tpl'] != '' ) {
    $tpl->load_template( $cat_info[$cat_idd]['short_tpl'] . '.tpl' );
} else {
    $tpl->load_template( 'shortstory.tpl' );
}

2 комментария

morefilms
Юзер

morefilms - 11 ноября 2014 23:57 -

ПафНутиЙ, к сожалению, ничего не изменилось, версия дле у меня 10.0

morefilms
Юзер

morefilms - 12 ноября 2014 01:05 -

Нашел другой способ, с ним rss работает, пока не увидел косяков других. Может кому еще пригодится:
Находим:
$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();
            }
        }

Чтобы комментировать - войдите или зарегистрируйтесь на сайте

Похожие вопросы

наверх