1

Тема: Проблемы с include на категориях

Приветь!

Сделал инклуд на категории чтоб при открывание  site.ru/cetegory1/   показал отдельный шаблон.

[category=1]{include file="team/c1.tpl"}[/category]

Все работает без проблем но google показывает ошибку 404 как лечить эту проблему?

Re: Проблемы с include на категориях

TITAN-UZ, А без инклуда все нормально?

3

Re: Проблемы с include на категориях

Я сделал так чтоб короткие новости были скрыты с  (site.ru/cetegory1/) на c1.tpl сделан меню с изображениями линьком на новость в этом категории.   

Все кроме этого категории работает без проблем!

Re: Проблемы с include на категориях

TITAN-UZ, Что-то у тебя с грамотой беда... Фиг поймешь, что ты хотел сказать sad
Так при редактировании категории в админке укажи индивидуальный шаблон, зачем велосипед сочинять?

5

Re: Проблемы с include на категориях

Sorry! По русски я не знаток?

Если указать шаблон в категории тогда этот меню повторяются.

6

Re: Проблемы с include на категориях

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

Идея такова: сделать для категории "1" отдельный шаблон чтобы в нем можно было выводить топ новости (категории "1") в левом блоке. Как можно организовать?

7 (07.05.2015 00:29 отредактировано svetlana)

Re: Проблемы с include на категориях

А в остальном шаблон будет тот же? Только топ другой?
топ стандартный или модуль?

8

Re: Проблемы с include на категориях

Шаблон планировалось сделать другой только для одной категории. Все остальное останется тоже самое

9

Re: Проблемы с include на категориях

В index.php
перед

$tpl->load_template ( 'main.tpl' );

вписать

if ($category_id == "ид категории") {$config['skin'] = "имя шаблона";}

но лучше найти причину по которой не работает стандартная функция, возможно что-то в init.php потерли.

10

Re: Проблемы с include на категориях

Добавил код if ($category_id == "19") {$config['skin'] = "novosti tehnologi";} все-равно ничего не меняется, работает основной шаблон который установлен по умолчанию...
Возможно ли как то подключить отдельно второй  main.tpl для этой категории, а не целиком шаблон?

11

Re: Проблемы с include на категориях

ну потому же принципу
только

$tpl->load_template ( 'main.tpl' );

заменить
на

if ($category_id == "19") {$tpl->load_template ( 'main_другой.tpl' );} 
else
{$tpl->load_template ( 'main.tpl' );}

Даже проверила и оба варианта работают нормально.

12 (08.05.2015 06:00 отредактировано xxEmagExx)

Re: Проблемы с include на категориях

C подключением разобрался, не подключалось из- за названия шаблона. А как можно вывести топ новости категории "19" чтобы отображались только новости этой категории

13

Re: Проблемы с include на категориях

Ну хотя бы так
заменить оригинальный topnews.php на это

+ открыть спойлер
<?php
/*
=====================================================
 DataLife Engine - by SoftNews Media Group 
-----------------------------------------------------
 http://dle-news.ru/
-----------------------------------------------------
 Copyright (c) 2004,2014 SoftNews Media Group
=====================================================
 Данный код защищен авторскими правами
=====================================================
 Файл: topnews.php
-----------------------------------------------------
 Назначение: вывод рейтинговых статей
=====================================================
*/

if( ! defined( 'DATALIFEENGINE' ) ) {
    die( "Hacking attempt!" );
}

if ($category_id == "19") {
    $tpl->result['topnews'] = dle_cache( "topnews19", $config['skin'], true );

if( $tpl->result['topnews'] === false ) {
    
    $this_month = date( 'Y-m-d H:i:s', $_TIME );

    $tpl->load_template( 'topnews.tpl' );

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

    $config['top_number'] = intval($config['top_number']);
    if ($config['top_number'] < 1 ) $config['top_number'] = 10;

    
    $db->query( "SELECT p.id, p.date, p.short_story, p.xfields, p.title, p.category, p.alt_name FROM " . PREFIX . "_post p LEFT JOIN " . PREFIX . "_post_extras e ON (p.id=e.news_id) WHERE p.category = '19' AND p.approve=1 AND p.date >= '$this_month' - INTERVAL 1 MONTH AND p.date < '$this_month' ORDER BY rating DESC, comm_num DESC, news_read DESC, date DESC LIMIT 0,{$config['top_number']}" );
    
    while ( $row = $db->get_row() ) {
        
        $row['date'] = strtotime( $row['date'] );

        if( ! $row['category'] ) {
            $my_cat = "---";
            $my_cat_link = "---";
        } else {
            
            $my_cat = array ();
            $my_cat_link = array ();
            $cat_list = explode( ',', $row['category'] );

            if ($config['category_separator'] != ',') $config['category_separator'] = ' '.$config['category_separator'];
         
            if( count( $cat_list ) == 1 ) {
                
                $my_cat[] = $cat_info[$cat_list[0]]['name'];
                
                $my_cat_link = get_categories( $cat_list[0], $config['category_separator'] );
            
            } else {
                
                foreach ( $cat_list as $element ) {
                    if( $element ) {
                        $my_cat[] = $cat_info[$element]['name'];
                        if( $config['allow_alt_url'] ) $my_cat_link[] = "<a href=\"" . $config['http_home_url'] . get_url( $element ) . "/\">{$cat_info[$element]['name']}</a>";
                        else $my_cat_link[] = "<a href=\"$PHP_SELF?do=cat&category={$cat_info[$element]['alt_name']}\">{$cat_info[$element]['name']}</a>";
                    }
                }
                
                $my_cat_link = implode( "{$config['category_separator']} ", $my_cat_link );
            }
            
            $my_cat = implode( "{$config['category_separator']} ", $my_cat );
        }

        $row['category'] = intval( $row['category'] );
        
        if( $config['allow_alt_url'] ) {
            
            if( $config['seo_type'] == 1 OR $config['seo_type'] == 2 ) {
                
                if( $row['category'] and $config['seo_type'] == 2 ) {
                    
                    $full_link = $config['http_home_url'] . get_url( $row['category'] ) . "/" . $row['id'] . "-" . $row['alt_name'] . ".html";
                
                } else {
                    
                    $full_link = $config['http_home_url'] . $row['id'] . "-" . $row['alt_name'] . ".html";
                
                }
            
            } else {
                
                $full_link = $config['http_home_url'] . date( 'Y/m/d/', $row['date'] ) . $row['alt_name'] . ".html";
            }
        
        } else {
            
            $full_link = $config['http_home_url'] . "index.php?newsid=" . $row['id'];
        
        }

        if( date( 'Ymd', $row['date'] ) == date( 'Ymd', $_TIME ) ) {
            
            $tpl->set( '{date}', $lang['time_heute'] . langdate( ", H:i", $row['date'] ) );
        
        } elseif( date( 'Ymd', $row['date'] ) == date( 'Ymd', ($_TIME - 86400) ) ) {
            
            $tpl->set( '{date}', $lang['time_gestern'] . langdate( ", H:i", $row['date'] ) );
        
        } else {
            
            $tpl->set( '{date}', langdate( $config['timestamp_active'], $row['date'] ) );
        
        }

        $news_date = $row['date'];
        $tpl->copy_template = preg_replace_callback ( "#\{date=(.+?)\}#i", "formdate", $tpl->copy_template );

        $tpl->set( '{category}', $my_cat );
        $tpl->set( '{link-category}', $my_cat_link );

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

        $row['title'] = str_replace( "{", "&#123;", $row['title'] );

        $tpl->set( '{title}', $row['title'] );
        
        if ( preg_match( "#\\{title limit=['\"](.+?)['\"]\\}#i", $tpl->copy_template, $matches ) ) {
            $count= intval($matches[1]);

            $row['title'] = strip_tags( $row['title'] );

            if( $count AND dle_strlen( $row['title'], $config['charset'] ) > $count ) {
                    
                $row['title'] = dle_substr( $row['title'], 0, $count, $config['charset'] );
                    
                if( ($temp_dmax = dle_strrpos( $row['title'], ' ', $config['charset'] )) ) $row['title'] = dle_substr( $row['title'], 0, $temp_dmax, $config['charset'] ). " ...";
                
            }

            $tpl->set( $matches[0], $row['title'] );

        }


        $tpl->set( '{link}', $full_link );

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

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

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

            $images = array();
            preg_match_all('/(img|src)=("|\')[^"\'>]+/i', $row['short_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( '{text}', $row['short_story'] );

        if ( preg_match( "#\\{text limit=['\"](.+?)['\"]\\}#i", $tpl->copy_template, $matches ) ) {
            $count= intval($matches[1]);

            $row['short_story'] = str_replace( "</p><p>", " ", $row['short_story'] );
            $row['short_story'] = strip_tags( $row['short_story'], "<br>" );
            $row['short_story'] = trim(str_replace( "<br>", " ", str_replace( "<br />", " ", str_replace( "\n", " ", str_replace( "\r", "", $row['short_story'] ) ) ) ));

            if( $count AND dle_strlen( $row['short_story'], $config['charset'] ) > $count ) {
                    
                $row['short_story'] = dle_substr( $row['short_story'], 0, $count, $config['charset'] );
                    
                if( ($temp_dmax = dle_strrpos( $row['short_story'], ' ', $config['charset'] )) ) $row['short_story'] = dle_substr( $row['short_story'], 0, $temp_dmax, $config['charset'] );
                
            }

            $tpl->set( $matches[0], $row['short_story'] );

        }

        // Обработка дополнительных полей
        if( $xfound ) {
            $xfieldsdata = xfieldsdataload( $row['xfields'] );
            
            foreach ( $xfields as $value ) {
                $preg_safe_name = preg_quote( $value[0], "'" );

                if ( $value[6] AND !empty( $xfieldsdata[$value[0]] ) ) {
                    $temp_array = explode( ",", $xfieldsdata[$value[0]] );
                    $value3 = array();

                    foreach ($temp_array as $value2) {

                        $value2 = trim($value2);
                        $value2 = str_replace("&#039;", "'", $value2);

                        if( $config['allow_alt_url'] ) $value3[] = "<a href=\"" . $config['http_home_url'] . "xfsearch/" . urlencode( $value2 ) . "/\">" . $value2 . "</a>";
                        else $value3[] = "<a href=\"$PHP_SELF?do=xfsearch&amp;xf=" . urlencode( $value2 ) . "\">" . $value2 . "</a>";
                    }

                    $xfieldsdata[$value[0]] = implode(", ", $value3);

                    unset($temp_array);
                    unset($value2);
                    unset($value3);

                }
        
                if( empty( $xfieldsdata[$value[0]] ) ) {
                    $tpl->copy_template = preg_replace( "'\\[xfgiven_{$preg_safe_name}\\](.*?)\\[/xfgiven_{$preg_safe_name}\\]'is", "", $tpl->copy_template );
                    $tpl->copy_template = str_replace( "[xfnotgiven_{$value[0]}]", "", $tpl->copy_template );
                    $tpl->copy_template = str_replace( "[/xfnotgiven_{$value[0]}]", "", $tpl->copy_template );
                } else {
                    $tpl->copy_template = preg_replace( "'\\[xfnotgiven_{$preg_safe_name}\\](.*?)\\[/xfnotgiven_{$preg_safe_name}\\]'is", "", $tpl->copy_template );
                    $tpl->copy_template = str_replace( "[xfgiven_{$value[0]}]", "", $tpl->copy_template );
                    $tpl->copy_template = str_replace( "[/xfgiven_{$value[0]}]", "", $tpl->copy_template );
                }
                
                $xfieldsdata[$value[0]] = stripslashes( $xfieldsdata[$value[0]] );

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

            }
        }
        // Обработка дополнительных полей


        $tpl->compile( 'topnews' );
    }

    $tpl->clear();    
    $db->free();

    create_cache( "topnews19", $tpl->result['topnews'], $config['skin'], true );
}
}

else

{
$tpl->result['topnews'] = dle_cache( "topnews", $config['skin'], true );

if( $tpl->result['topnews'] === false ) {
    
    $this_month = date( 'Y-m-d H:i:s', $_TIME );

    $tpl->load_template( 'topnews.tpl' );

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

    $config['top_number'] = intval($config['top_number']);
    if ($config['top_number'] < 1 ) $config['top_number'] = 10;

    
    $db->query( "SELECT p.id, p.date, p.short_story, p.xfields, p.title, p.category, p.alt_name FROM " . PREFIX . "_post p LEFT JOIN " . PREFIX . "_post_extras e ON (p.id=e.news_id) WHERE p.approve=1 AND p.date >= '$this_month' - INTERVAL 1 MONTH AND p.date < '$this_month' ORDER BY rating DESC, comm_num DESC, news_read DESC, date DESC LIMIT 0,{$config['top_number']}" );
    
    while ( $row = $db->get_row() ) {
        
        $row['date'] = strtotime( $row['date'] );

        if( ! $row['category'] ) {
            $my_cat = "---";
            $my_cat_link = "---";
        } else {
            
            $my_cat = array ();
            $my_cat_link = array ();
            $cat_list = explode( ',', $row['category'] );

            if ($config['category_separator'] != ',') $config['category_separator'] = ' '.$config['category_separator'];
         
            if( count( $cat_list ) == 1 ) {
                
                $my_cat[] = $cat_info[$cat_list[0]]['name'];
                
                $my_cat_link = get_categories( $cat_list[0], $config['category_separator'] );
            
            } else {
                
                foreach ( $cat_list as $element ) {
                    if( $element ) {
                        $my_cat[] = $cat_info[$element]['name'];
                        if( $config['allow_alt_url'] ) $my_cat_link[] = "<a href=\"" . $config['http_home_url'] . get_url( $element ) . "/\">{$cat_info[$element]['name']}</a>";
                        else $my_cat_link[] = "<a href=\"$PHP_SELF?do=cat&category={$cat_info[$element]['alt_name']}\">{$cat_info[$element]['name']}</a>";
                    }
                }
                
                $my_cat_link = implode( "{$config['category_separator']} ", $my_cat_link );
            }
            
            $my_cat = implode( "{$config['category_separator']} ", $my_cat );
        }

        $row['category'] = intval( $row['category'] );
        
        if( $config['allow_alt_url'] ) {
            
            if( $config['seo_type'] == 1 OR $config['seo_type'] == 2 ) {
                
                if( $row['category'] and $config['seo_type'] == 2 ) {
                    
                    $full_link = $config['http_home_url'] . get_url( $row['category'] ) . "/" . $row['id'] . "-" . $row['alt_name'] . ".html";
                
                } else {
                    
                    $full_link = $config['http_home_url'] . $row['id'] . "-" . $row['alt_name'] . ".html";
                
                }
            
            } else {
                
                $full_link = $config['http_home_url'] . date( 'Y/m/d/', $row['date'] ) . $row['alt_name'] . ".html";
            }
        
        } else {
            
            $full_link = $config['http_home_url'] . "index.php?newsid=" . $row['id'];
        
        }

        if( date( 'Ymd', $row['date'] ) == date( 'Ymd', $_TIME ) ) {
            
            $tpl->set( '{date}', $lang['time_heute'] . langdate( ", H:i", $row['date'] ) );
        
        } elseif( date( 'Ymd', $row['date'] ) == date( 'Ymd', ($_TIME - 86400) ) ) {
            
            $tpl->set( '{date}', $lang['time_gestern'] . langdate( ", H:i", $row['date'] ) );
        
        } else {
            
            $tpl->set( '{date}', langdate( $config['timestamp_active'], $row['date'] ) );
        
        }

        $news_date = $row['date'];
        $tpl->copy_template = preg_replace_callback ( "#\{date=(.+?)\}#i", "formdate", $tpl->copy_template );

        $tpl->set( '{category}', $my_cat );
        $tpl->set( '{link-category}', $my_cat_link );

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

        $row['title'] = str_replace( "{", "&#123;", $row['title'] );

        $tpl->set( '{title}', $row['title'] );
        
        if ( preg_match( "#\\{title limit=['\"](.+?)['\"]\\}#i", $tpl->copy_template, $matches ) ) {
            $count= intval($matches[1]);

            $row['title'] = strip_tags( $row['title'] );

            if( $count AND dle_strlen( $row['title'], $config['charset'] ) > $count ) {
                    
                $row['title'] = dle_substr( $row['title'], 0, $count, $config['charset'] );
                    
                if( ($temp_dmax = dle_strrpos( $row['title'], ' ', $config['charset'] )) ) $row['title'] = dle_substr( $row['title'], 0, $temp_dmax, $config['charset'] ). " ...";
                
            }

            $tpl->set( $matches[0], $row['title'] );

        }


        $tpl->set( '{link}', $full_link );

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

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

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

            $images = array();
            preg_match_all('/(img|src)=("|\')[^"\'>]+/i', $row['short_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( '{text}', $row['short_story'] );

        if ( preg_match( "#\\{text limit=['\"](.+?)['\"]\\}#i", $tpl->copy_template, $matches ) ) {
            $count= intval($matches[1]);

            $row['short_story'] = str_replace( "</p><p>", " ", $row['short_story'] );
            $row['short_story'] = strip_tags( $row['short_story'], "<br>" );
            $row['short_story'] = trim(str_replace( "<br>", " ", str_replace( "<br />", " ", str_replace( "\n", " ", str_replace( "\r", "", $row['short_story'] ) ) ) ));

            if( $count AND dle_strlen( $row['short_story'], $config['charset'] ) > $count ) {
                    
                $row['short_story'] = dle_substr( $row['short_story'], 0, $count, $config['charset'] );
                    
                if( ($temp_dmax = dle_strrpos( $row['short_story'], ' ', $config['charset'] )) ) $row['short_story'] = dle_substr( $row['short_story'], 0, $temp_dmax, $config['charset'] );
                
            }

            $tpl->set( $matches[0], $row['short_story'] );

        }

        // Обработка дополнительных полей
        if( $xfound ) {
            $xfieldsdata = xfieldsdataload( $row['xfields'] );
            
            foreach ( $xfields as $value ) {
                $preg_safe_name = preg_quote( $value[0], "'" );

                if ( $value[6] AND !empty( $xfieldsdata[$value[0]] ) ) {
                    $temp_array = explode( ",", $xfieldsdata[$value[0]] );
                    $value3 = array();

                    foreach ($temp_array as $value2) {

                        $value2 = trim($value2);
                        $value2 = str_replace("&#039;", "'", $value2);

                        if( $config['allow_alt_url'] ) $value3[] = "<a href=\"" . $config['http_home_url'] . "xfsearch/" . urlencode( $value2 ) . "/\">" . $value2 . "</a>";
                        else $value3[] = "<a href=\"$PHP_SELF?do=xfsearch&amp;xf=" . urlencode( $value2 ) . "\">" . $value2 . "</a>";
                    }

                    $xfieldsdata[$value[0]] = implode(", ", $value3);

                    unset($temp_array);
                    unset($value2);
                    unset($value3);

                }
        
                if( empty( $xfieldsdata[$value[0]] ) ) {
                    $tpl->copy_template = preg_replace( "'\\[xfgiven_{$preg_safe_name}\\](.*?)\\[/xfgiven_{$preg_safe_name}\\]'is", "", $tpl->copy_template );
                    $tpl->copy_template = str_replace( "[xfnotgiven_{$value[0]}]", "", $tpl->copy_template );
                    $tpl->copy_template = str_replace( "[/xfnotgiven_{$value[0]}]", "", $tpl->copy_template );
                } else {
                    $tpl->copy_template = preg_replace( "'\\[xfnotgiven_{$preg_safe_name}\\](.*?)\\[/xfnotgiven_{$preg_safe_name}\\]'is", "", $tpl->copy_template );
                    $tpl->copy_template = str_replace( "[xfgiven_{$value[0]}]", "", $tpl->copy_template );
                    $tpl->copy_template = str_replace( "[/xfgiven_{$value[0]}]", "", $tpl->copy_template );
                }
                
                $xfieldsdata[$value[0]] = stripslashes( $xfieldsdata[$value[0]] );

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

            }
        }
        // Обработка дополнительных полей


        $tpl->compile( 'topnews' );
    }

    $tpl->clear();    
    $db->free();

    create_cache( "topnews", $tpl->result['topnews'], $config['skin'], true );
}
}
?>