Скрыть объявление
ВАШИ ПРАВА ОГРАНИЧЕНЫ!

Зарегистрируйтесь на форуме, чтобы стать полноценным участником сообщества!

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

Тема в разделе "Вопросы- ответы", создана пользователем never3d22, 17 мар 2016.

17.03.16 в 22:22
18.03.16 в 02:30
11
1.413
0
  1. TopicStarter Overlay
    never3d22

    Забанен

    Регистрация:
    3 дек 2015
    Сообщения:
    1.021
    Лучших ответов:
    0
    Рейтинги:
    +110 / 0 / -0
    Как включить обработку доп.полей в php модуле DLE?
    $xfieldsdata = xfieldsdataload( $row['xfields'] ); не работает что-то
     
  2. TopicStarter Overlay
    never3d22

    Забанен

    Регистрация:
    3 дек 2015
    Сообщения:
    1.021
    Лучших ответов:
    0
    Рейтинги:
    +110 / 0 / -0
    как в сторонний модуль топ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();
    }
    ?>
     
  3. PunPun

    VIP Кинотрафик v2

    Регистрация:
    11 июн 2015
    Сообщения:
    7.292
    Лучших ответов:
    31
    Рейтинги:
    +3.892 / 96 / -0
    Мне жаль вас, там используется API от DLE
     
  4. TopicStarter Overlay
    never3d22

    Забанен

    Регистрация:
    3 дек 2015
    Сообщения:
    1.021
    Лучших ответов:
    0
    Рейтинги:
    +110 / 0 / -0
    Спасибо а в api нет доп. Полей? Или как подключить
     
  5. TopicStarter Overlay
    never3d22

    Забанен

    Регистрация:
    3 дек 2015
    Сообщения:
    1.021
    Лучших ответов:
    0
    Рейтинги:
    +110 / 0 / -0
  6. nylmen

    Команда форума VIP Кинотрафик v2

    Регистрация:
    2 ноя 2015
    Сообщения:
    2.574
    Лучших ответов:
    0
    Рейтинги:
    +702 / 2 / -0
    https://ru.wikipedia.org/wiki/API
     
  7. TopicStarter Overlay
    never3d22

    Забанен

    Регистрация:
    3 дек 2015
    Сообщения:
    1.021
    Лучших ответов:
    0
    Рейтинги:
    +110 / 0 / -0
    $fields - перечень получаемых полей новостей или * для всех
     
  8. PunPun

    VIP Кинотрафик v2

    Регистрация:
    11 июн 2015
    Сообщения:
    7.292
    Лучших ответов:
    31
    Рейтинги:
    +3.892 / 96 / -0
    из для начала подключит в запросе нужно, а потом делать вызов функции которая сделает ассоциативный массив. и api dle очень медленное, по этому мне жаль что вы используете такой шлак.
     
  9. TopicStarter Overlay
    never3d22

    Забанен

    Регистрация:
    3 дек 2015
    Сообщения:
    1.021
    Лучших ответов:
    0
    Рейтинги:
    +110 / 0 / -0
    Ок. Понятно. Значит придется custom использовать и делать редирект с .html. А у вас случаем нету наработки как сделать топ новостей?
     
  10. PunPun

    VIP Кинотрафик v2

    Регистрация:
    11 июн 2015
    Сообщения:
    7.292
    Лучших ответов:
    31
    Рейтинги:
    +3.892 / 96 / -0
    Есть у меня такой хак. Купи Block.Pro от Пафнутия. 420 рублей не так дорого - http://store.pafnuty.name/15-blockpro.html
     
  11. TopicStarter Overlay
    never3d22

    Забанен

    Регистрация:
    3 дек 2015
    Сообщения:
    1.021
    Лучших ответов:
    0
    Рейтинги:
    +110 / 0 / -0
    Да придется приобрести... Галимый апи, когда его уже сделают нормальным
     
  12. iNol

    Команда форума VIP Кинотрафик v2

    Регистрация:
    14 сен 2015
    Сообщения:
    476
    Лучших ответов:
    0
    Рейтинги:
    +306 / 0 / -0
    global $row;
     
Похожие темы
  1. djusel
    Ответов:
    14
    Просмотров:
    1.963
  2. Serhii
    Ответов:
    27
    Просмотров:
    3.931
  3. film
    Ответов:
    10
    Просмотров:
    1.519
  4. 234865793243
    Ответов:
    6
    Просмотров:
    1.689
  5. Frosty
    Ответов:
    2
    Просмотров:
    780
Загрузка...
Яндекс.Метрика