Перейти к содержанию
View in the app

A better way to browse. Learn more.

Форум VAOZ.RU

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Отображение текста для определенных новостей в шаблоне main.tpl

Featured Replies

Опубликовано

Иногда возникает потребность в том, чтобы какую-то информацию из шаблона main.tpl не отображать для определенной новости.

Данных хак позволит выводить или скрывать текст для конкретных новостей.

Открываем index.php

Найти

$tpl->set ( '{calendar}', $tpl->result['calendar'] );

Добавить ВЫШЕ

if($dle_module == "showfull") {
$news_id = $_GET['newsid'];
  
                if( strpos( $tpl->copy_template, "[not-newsid=" ) !== false ) {
                        $tpl->copy_template = preg_replace( "#\\[not-newsid=(.+?)\\](.*?)\\[/not-newsid\\]#ies", "check_newsid('\\1', '\\2', '{$news_id}', false)", $tpl->copy_template );
                }
                if( strpos( $tpl->copy_template, "[newsid=" ) !== false ) {
                        $tpl->copy_template = preg_replace ( "#\\[newsid=(.+?)\\](.*?)\\[/newsid\\]#ies", "check_newsid('\\1', '\\2', '{$news_id}')", $tpl->copy_template );
                }
                        $tpl->set_block( "'\\[cattext\\](.*?)\\[/cattext\\]'si", "" );
} else {
                        $tpl->set( '[cattext]', "" );
                        $tpl->set( '[/cattext]', "" );
                        $tpl->copy_template = preg_replace ( "#\\[newsid=(.+?)\\](.*?)\\[/newsid\\]#ies", "", $tpl->copy_template );
                        $tpl->copy_template = preg_replace ( "#\\[not-newsid=(.+?)\\](.*?)\\[/not-newsid\\]#ies", "", $tpl->copy_template );
  
}

Открываем engine/modules/functions.php

Найти

function check_category($cats, $block, $category, $action = true) {

Добавить ВЫШЕ

function check_newsid($cats, $block, $category, $action = true) {
  
        $cats = str_replace(" ", "", $cats );   
        $cats = explode( ',', $cats );
        $category = explode( ',', $category );
        $found = false;
         
        foreach ( $category as $element ) {
                 
                if( $action ) {
                         
                        if( in_array( $element, $cats ) ) {
                                 
                                $block = str_replace( '\"', '"', $block );
                                return $block;
                        }
                 
                } else {
                         
                        if( in_array( $element, $cats ) ) {
                                $found = true;
                        }
                 
                }
         
        }
  
        if ( !$action AND !$found ) {   
  
                $block = str_replace( '\"', '"', $block  );
                return $block;
        }
  
        return "";
  
}


В main.tpl можно вставлять комбинации

[newsid=1,2] текст [/newsid]
[not-newsid=3] текст [/not-newsid]

Для публикации сообщений создайте учётную запись или авторизуйтесь

https://vaoz.ru/topic/318-otobrazhenie-teksta-dlya-opredelennyh-novostej-v-shablone-maintpl/
Рейтинг@Mail.ru Яндекс.Метрика

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.