Редактор темы

Подключение доп.полей в сторонний модуль

never3d22

Забанен
Регистрация
3 Дек 2015
Сообщения
1.014
Рейтинг реакций
100
Баллы
63
1/3
Автор темы
Как включить обработку доп.полей в php модуле DLE?
$xfieldsdata = xfieldsdataload( $row['xfields'] ); не работает что-то
 
Автор темы
как в сторонний модуль топ100 добавить поддержку шаблона с доп.полеми
Код:
<?php

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

if ($_GET['mode']!='views' and $_GET['mode']!='comments' and $_GET['mode']!='rating') {
  msgbox( $lang['all_err_1'], $lang['news_err_27'] );
}

include ENGINE_DIR . '/data/top100.config.php';
include ENGINE_DIR . '/api/api.class.php';
if ($_GET['mode']=='views'){
    $cache = $dle_api->load_from_cache ( "top100views",  3600, $tpl->result['content'] );
    if( $cache === false ) {
        if ($top100_config['category'] != 0){
            $category_true = "AND category IN (".$top100_config['category'].")";
        } else {
            $category_true = "";
        }

    $sql_result = $db->query( "SELECT p.id, p.title, p.category, p.alt_name, e.news_read, '1' as flag FROM " . PREFIX . "_post as p LEFT JOIN " . PREFIX . "_post_extras e ON (p.id=e.news_id) WHERE approve=1 ".$category_true." ORDER BY e.news_read DESC LIMIT ".$top100_config['news_num'] );

$top100 = <<<HTML
    <thead>
        <tr>
            <td align="center">$top100_config[title_num]</td>
            <td align="center">$top100_config[title_name]</td>
            <td align="center">$top100_config[title_views_head]</td>
        </tr>
    </thead>
HTML;
$top100 .= <<<HTML
<tbody>
HTML;
$i=1;
while ( $row = $db->get_row($sql_result) ) {
$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'];

}

$row['title']=strip_tags( stripslashes( $row['title'] ) );
$row['news_read']=strip_tags( stripslashes( $row['news_read'] ) );
$full_link=strip_tags( stripslashes( $full_link ) );

$top100 .='';

if ($row['news_read']!=0){
$top100 .= <<<HTML
    <tr>
        <td align="center">&nbsp;&nbsp;$i&nbsp;&nbsp;</td>
        <td><a href="$full_link" title=""><strong>$row[title]</strong></a></td>
        <td align="center">$row[news_read]</td>
    </tr>
HTML;

$i++;
}
}

$top100 .= <<<HTML
</tbody>
HTML;
$tpl->load_template( 'top100.tpl' );
$tpl->set( '{title}', $top100_config['title_views'] );
$tpl->set( '{title1}', $top100_config['title_comments'] );
$tpl->set( '{title2}', $top100_config['title_rating'] );
$tpl->set( '{top100}', $top100 );
$tpl->compile( 'content' );
$dle_api->save_to_cache ( "top100views", $tpl->result['content'] );
}
else {
    var_dump($cache);
}
$tpl->clear();
$db->free();
}

if ($_GET['mode']=='comments'){
$cache = $dle_api->load_from_cache ( "top100comments",  3600, $tpl->result['content'] );
if( $cache === false ) {
if ($top100_config['category'] != 0){
$category_true = "AND category IN (".$top100_config['category'].")";
} else {
$category_true = "";
}

$sql_result = $db->query( "SELECT id, title, category, alt_name, comm_num FROM " . PREFIX . "_post WHERE approve=1 ".$category_true." ORDER BY comm_num DESC LIMIT ".$top100_config['news_num'] );

$top100 = <<<HTML
    <thead>
        <tr>
            <td align="center">$top100_config[title_num]</td>
            <td align="center">$top100_config[title_name]</td>
            <td align="center">$top100_config[title_comments_head]</td>
        </tr>
    </thead>
HTML;
$top100 .= <<<HTML
<tbody>
HTML;
$i=1;
while ( $row = $db->get_row($sql_result) ) {
$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'];
}

$row['title']=strip_tags( stripslashes( $row['title'] ) );
$row['comm_num']=strip_tags( stripslashes( $row['comm_num'] ) );
$full_link=strip_tags( stripslashes( $full_link ) );

if ($row['comm_num']!=0){
$top100 .= <<<HTML
    <tr>
        <td align="center">&nbsp;&nbsp;$i&nbsp;&nbsp;</td>
        <td><a href="$full_link" title=""><strong>$row[title]</strong></a></td>
        <td align="center">$row[comm_num]</td>
    </tr>
HTML;

$i++;
}

}
$top100 .= <<<HTML
</tbody>
HTML;
$tpl->load_template( 'top100.tpl' );
$tpl->set( '{title}', $top100_config['title_views'] );
$tpl->set( '{title1}', $top100_config['title_comments'] );
$tpl->set( '{title2}', $top100_config['title_rating'] );
$tpl->set( '{top100}', $top100 );
$tpl->compile( 'content' );
$dle_api->save_to_cache ( "top100comments", $tpl->result['content'] );
}
else {
    var_dump($cache);
}
$tpl->clear();
$db->free();
}

if ($_GET['mode']=='rating'){
$cache = $dle_api->load_from_cache ( "top100rating",  3600, $tpl->result['content'] );
if( $cache === false ) {
if ($top100_config['category'] != 0){
$category_true = "AND category IN (".$top100_config['category'].")";
} else {
$category_true = "";
}

$sql_result = $db->query( "SELECT p.id, p.title, p.category, p.alt_name, e.allow_rate, e.rating, '1' as flag FROM " . PREFIX . "_post as p LEFT JOIN " . PREFIX . "_post_extras e ON (p.id=e.news_id) WHERE approve=1 ".$category_true." ORDER BY e.rating DESC LIMIT ".$top100_config['news_num'] );

$top100 = <<<HTML
    <thead>
        <tr>
            <td align="center">$top100_config[title_num]</td>
            <td align="center">$top100_config[title_name]</td>
            <td align="center">$top100_config[title_rating_head]</td>
        </tr>
    </thead>
HTML;
$top100 .= <<<HTML
<tbody>
HTML;
$i=1;
while ( $row = $db->get_row($sql_result) ) {
$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'];
}

$row['title']=strip_tags( stripslashes( $row['title'] ) );
$row['rating']=strip_tags( stripslashes( $row['rating'] ) );
$full_link=strip_tags( stripslashes( $full_link ) );

if ($row['rating']!=0){
$top100 .= <<<HTML
    <tr>
        <td align="center">&nbsp;&nbsp;$i&nbsp;&nbsp;</td>
        <td><a href="$full_link" title=""><strong>$row[title]</strong></a></td>
        <td align="center">$row[rating]</td>
    </tr>
HTML;

$i++;
}

}
$top100 .= <<<HTML
</tbody>
HTML;
$tpl->load_template( 'top100.tpl' );
$tpl->set( '{title}', $top100_config['title_views'] );
$tpl->set( '{title1}', $top100_config['title_comments'] );
$tpl->set( '{title2}', $top100_config['title_rating'] );
$tpl->set( '{top100}', $top100 );
$tpl->compile( 'content' );
$dle_api->save_to_cache ( "top100rating", $tpl->result['content'] );
}
else {
    var_dump($cache);
}
$tpl->clear();
$db->free();
}
?>
 
Мне жаль вас, там используется API от DLE
 
Автор темы
$fields будет работать?
 
$fields - перечень получаемых полей новостей или * для всех
из для начала подключит в запросе нужно, а потом делать вызов функции которая сделает ассоциативный массив. и api dle очень медленное, по этому мне жаль что вы используете такой шлак.
 
Автор темы
из для начала подключит в запросе нужно, а потом делать вызов функции которая сделает ассоциативный массив. и api dle очень медленное, по этому мне жаль что вы используете такой шлак.
Ок. Понятно. Значит придется custom использовать и делать редирект с .html. А у вас случаем нету наработки как сделать топ новостей?
 
Автор темы

Похожие темы Последние темы Популярные темы

Назад
Сверху