Не нравятся результаты поиска? Попробуйте другой поиск!
DLE FAQ » Все вопросы » Шаблоны (TPL) » Как вывести {full-story limit=""} в краткой новости на DLE 10.3?

Как вывести {full-story limit=""} в краткой новости на DLE 10.3?


     25.02.2015    Шаблоны (TPL), Общие вопросы по PHP, Хаки    5315

вопрос
Добрый день!
Подскажите пожалуйста, как вывести тег {full-story limit="600"} в краткой новости, статистической странице (используется тот же шаблон что и в категории), в результатах поиска и в избранном? Когда прописываю, в краткой новости вместо текста надпись {full-story limit="600"}.

На сайте много категорий и в 2-х нужно именно в коротких новостях выводилось описание с полной + что бы нормально отображалось в статике, закладках и в поиске.
Использую DLE 10.3

Заранее благодарю за помощь.

Ответа пока нет


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

boltuk
Юзер

boltuk - 27 февраля 2015 19:32 -

Товарищи, помогите с проблемой. Для вывода full-story и image-full нашел решение от VITNET, ниже приведу его пример, а вот как это же вывести на статистических страницах, в поиске и в закладках, не знаю.....


Файл engine.php
найти (их 13 шт.)
CHAR_LENGTH(p.full_story) as full_story,


заменить на (привести в такой вид)
CHAR_LENGTH(p.full_story) as full_story, p.full_story,


engine/modules/show.short.php
найти
if( isset($view_template) AND $view_template == "rss" ) {
            
            $tpl->set( '{rsslink}', $full_link );
            $tpl->set( '{rssauthor}', $row['autor'] );
            ...
            ...


Добавить выше
$row['full_story'] = stripslashes($row['full_story']);

        // out this tags "{image-full-x}"
        if( stripos ( $tpl->copy_template, "{image-full-" ) !== false ) {
            $images = array();
            preg_match_all('/(img|src)=("|\')[^"\'>]+/i', $row['full_story'], $media);
            $data = preg_replace('/(img|src)("|\'|="|=\')(.*)/i',"$3",$media[0]);
    
            foreach($data as $url) {
                $info = pathinfo($url);
                if( isset($info['extension']) ) {
                    $info['extension'] = strtolower($info['extension']);
                    if( ($info['extension'] == 'jpg') || ($info['extension'] == 'jpeg') || ($info['extension'] == 'gif') || ($info['extension'] == 'png') ) array_push($images, $url);
                }
            }
    
            if( count($images) ) {
                $i_count = 0;
                foreach($images as $url) {
                    $i_count++;
                    $tpl->copy_template = str_replace( '{image-full-' . $i_count . '}', $url, $tpl->copy_template );
                    $tpl->copy_template = str_replace( '[image-full-' . $i_count . ']', "", $tpl->copy_template );
                    $tpl->copy_template = str_replace( '[/image-full-'. $i_count . ']', "", $tpl->copy_template );
                }
            }

            $tpl->copy_template = preg_replace( "#\[image-full-(.+?)\](.+?)\[/image-full-(.+?)\]#is", "", $tpl->copy_template );
            $tpl->copy_template = preg_replace( "#\\{image-full-(.+?)\\}#i", "{THEME}/dleimages/no_image.jpg", $tpl->copy_template );
        }
        // out this tags "{image-full-x}"

        // out this tags "{full-story limit="x"}"
        if( preg_match( "#\\{full-story limit=['\"](.+?)['\"]\\}#i", $tpl->copy_template, $matches ) ) {
            $count = intval($matches[1]);

            $row['full-story'] = str_replace( "</p><p>", " ", $row['full_story'] );
            $row['full-story'] = strip_tags( $row['full-story'], "<br>" );
            $row['full-story'] = trim(str_replace( "<br>", " ", str_replace( "<br />", " ", str_replace( "\n", " ", str_replace( "\r", "", $row['full-story'] ) ) ) ));
    
            if( $count AND dle_strlen( $row['full-story'], $config['charset'] ) > $count ) {
                $row['full-story'] = dle_substr( $row['full-story'], 0, $count, $config['charset'] );
                if( ($temp_dmax = dle_strrpos( $row['full-story'], ' ', $config['charset'] )) ) $row['full-story'] = dle_substr( $row['full-story'], 0, $temp_dmax, $config['charset'] );
            }
    
            $tpl->set( $matches[0], $row['full-story'] );
        } else {
            $tpl->set( '{full-story}', $row['full_story'] );
        }
        // out this tags "{full-story limit=x}"


в шаблоне коротких новостей использовать теги
{full-story limit="XX"}
{image-full-X}

boltuk
Юзер

boltuk - 1 марта 2015 19:02 -

Народ, помогите пожалуйста решить проблему

SergiooU
Юзер

SergiooU - 4 января 2018 13:38 -

boltuk,Dle 12
/engine/modules/function.php, ищем:
PHP:
 $sql_select = "SELECT p.id, p.autor, p.date, p.short_story, CHAR_LENGTH(p.full_story) as full_story, p.xfields, p.title, p.category, p.alt_name, p.comm_num, p.allow_comm, p.fixed, p.tags, e.news_read, e.allow_rate, e.rating, e.vote_num, e.votes, e.view_edit, e.editdate, e.editor, e.reason FROM " . PREFIX . "_post p LEFT JOIN " . PREFIX . "_post_extras e ON (p.id=e.news_id)";

Меняем на:
PHP:
 $sql_select = "SELECT p.id, p.autor, p.date, p.short_story, CHAR_LENGTH(p.full_story) as full_story, p.full_story as full__story, p.xfields, p.title, p.category, p.alt_name, p.comm_num, p.allow_comm, p.fixed, p.tags, e.news_read, e.allow_rate, e.rating, e.vote_num, e.votes, e.view_edit, e.editdate, e.editor, e.reason FROM " . PREFIX . "_post p LEFT JOIN " . PREFIX . "_post_extras e ON (p.id=e.news_id)";

/engine/modules/show.custom.php ищем:
PHP:
$tpl->compile( 'content' );

Вставляем:
PHP:
 if ($smartphone_detected) {

        if (!$config['allow_smart_format']) {

                $row['full__story'] = strip_tags( $row['full__story'], '<p><br><a>' );

        } else {


            if ( !$config['allow_smart_images'] ) {
    
                $row['full__story'] = preg_replace( "#<!--TBegin-->(.+?)<!--TEnd-->#is", "", $row['full__story'] );
                $row['full__story'] = preg_replace( "#<img(.+?)>#is", "", $row['full__story'] );
    
            }
    
            if ( !$config['allow_smart_video'] ) {
    
                $row['full__story'] = preg_replace( "#<!--dle_video_begin(.+?)<!--dle_video_end-->#is", "", $row['full__story'] );
                $row['full__story'] = preg_replace( "#<!--dle_audio_begin(.+?)<!--dle_audio_end-->#is", "", $row['full__story'] );
    
            }

        }

    }

    $row['full__story'] = stripslashes( $row['full__story'] );

    if( $user_group[$member_id['user_group']]['allow_hide'] ) $row['full__story'] = str_ireplace( "[hide]", "", str_ireplace( "[/hide]", "", $row['full__story']) );
    else $row['full__story'] = preg_replace ( "#\[hide\](.+?)\[/hide\]#ims", "<div class=\"quote\">" . $lang['news_regus'] . "</div>", $row['full__story'] );

    if (stripos ( $tpl->copy_template, "{image-" ) !== false) {

        $images = array();
        preg_match_all('/(img|src)=("|\')[^"\'>]+/i', $row['full__story'], $media);
        $data=preg_replace('/(img|src)("|\'|="|=\')(.*)/i',"$3",$media[0]);

        foreach($data as $url) {
            $info = pathinfo($url);
            if (isset($info['extension'])) {
                if ($info['filename'] == "spoiler-plus" OR $info['filename'] == "spoiler-plus" ) continue;
                $info['extension'] = strtolower($info['extension']);
                if (($info['extension'] == 'jpg') || ($info['extension'] == 'jpeg') || ($info['extension'] == 'gif') || ($info['extension'] == 'png')) array_push($images, $url);
            }
        }

        if ( count($images) ) {
            $i=0;
            foreach($images as $url) {
                $i++;
                $tpl->copy_template = str_replace( '{image-'.$i.'}', $url, $tpl->copy_template );
                $tpl->copy_template = str_replace( '[image-'.$i.']', "", $tpl->copy_template );
                $tpl->copy_template = str_replace( '[/image-'.$i.']', "", $tpl->copy_template );
            }

        }

        $tpl->copy_template = preg_replace( "#\[image-(.+?)\](.+?)\[/image-(.+?)\]#is", "", $tpl->copy_template );
        $tpl->copy_template = preg_replace( "#\\{image-(.+?)\\}#i", "{THEME}/dleimages/no_image.jpg", $tpl->copy_template );

    }

    $tpl->set( '{full-story}', $row['full__story'] );

    if ( preg_match( "#\\{full-story limit=['\"](.+?)['\"]\\}#i", $tpl->copy_template, $matches ) ) {
        $count= intval($matches[1]);
    
        $row['full__story'] = str_replace( "</p><p>", " ", $row['full__story'] );
        $row['full__story'] = strip_tags( $row['full__story'], "<br>" );
        $row['full__story'] = trim(str_replace( "<br>", " ", str_replace( "<br />", " ", str_replace( "\n", " ", str_replace( "\r", "", $row['full__story'] ) ) ) ));
    
        if( $count AND dle_strlen( $row['full__story'], $config['charset'] ) > $count ) {
                        
            $row['full__story'] = dle_substr( $row['full__story'], 0, $count, $config['charset'] );
                        
            if( ($temp_dmax = dle_strrpos( $row['full__story'], ' ', $config['charset'] )) ) $row['full__story'] = dle_substr( $row['full__story'], 0, $temp_dmax, $config['charset'] );
                    
        }
    
        $tpl->set( $matches[0], $row['full__story']);
    
    }

Как-то так...

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

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

наверх