Перейти к публикации
View in the app

A better way to browse. Learn more.

Дизайн и модификация Invision Community

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.

[IPB 3.1.4] Добавляем возможность указания баннера для каждого форума в отдельности

(0 отзывов)

Главный админ портала захотел определять рекламный блок в шапке для каждого подфорума в отдельности, а не только глобальный. Немного полазив по исходникам IPB 3.1.4 было решено сделать такую возможность. На всю реализацию затеи ушло 1,5 часа (вместе с проверкой).

 

Для начала полазил по Админской Панели и нашёл место, в котором указываются стандартные рекламные блоки:

sh_0010.png

 

Выяснил, что код рекламных блоков хранится в таблице core_sys_conf_settings. За рекламные блоки в шапке отвечают следующие записи: ad_code_global_header , ad_code_board_index_header , ad_code_forum_view_header. Именно параметр ad_code_forum_view_header отвечает за отрисовку баннера в форумах.

 

Руководство к действию.

 

Через phpMyAdmin добавляем в таблицу forums новое поле banner (тип TEXT, сравнение utf8_general_ci):

sh_0013.png

Проверьте, что данное поле появилось.

 

Открываем на редактирование файл /admin/applications/forums/modules_admin/forums/forums.php и ищем следующий код:

'description'				=> '',
'status'					=> 0,

который заменяем на такой кодес:

'description'				=> '',
'banner'				=> '',
'status'					=> 0,

 

Чуть ниже находим кодес такого содержания:

'description'				=> '',
'status'					=> 1,

который заменяем на такой кодес:

'description'				=> '',
'banner'				=> '',
'status'					=> 1,

 

Ещё ниже находм следующий участок:

$form['sub_can_post'] = $this->registry->output->formYesNo(  'sub_can_post', ( isset($_POST['sub_can_post']) AND $_POST['sub_can_post'] )         ? $_POST['sub_can_post'] : ( $forum['sub_can_post'] == 1 ? 0 : 1 ) );

и заменяем его на:

$form['sub_can_post'] = $this->registry->output->formYesNo(  'sub_can_post', ( isset($_POST['sub_can_post']) AND $_POST['sub_can_post'] )         ? $_POST['sub_can_post'] : ( $forum['sub_can_post'] == 1 ? 0 : 1 ) );
$form['banner']       = $this->registry->output->formTextarea("banner"      , IPSText::br2nl( ( isset( $_POST['banner']) AND $_POST['banner'] ) ? $_POST['banner'] : $forum['banner'] ) , 120, 5 );

Как раз тут указываются размеры поля ввода кода рекламного баннера в шапке (ширина: 120, высота: 5).

 

Далее находим кодес:

'description'             => IPSText::getTextClass('bbcode')->xssHtmlClean( nl2br( IPSText::stripslashes( $_POST['description'] ) ) ),
'use_ibc'                 => intval($this->request['use_ibc']),

который меняем на такой:

'description'             => IPSText::getTextClass('bbcode')->xssHtmlClean( nl2br( IPSText::stripslashes( $_POST['description'] ) ) ),
'banner'                  => nl2br( IPSText::stripslashes($_POST['banner']) ),
'use_ibc'                 => intval($this->request['use_ibc']),

 

Сохраняем файл /admin/applications/forums/modules_admin/forums/forums.php и копируем его на WEB-сервер.

 

 

Открываем на редактирование файл /admin/applications/forums/modules_public/forums/forums.php и ищем следующий код:

    /* Set Ad code for the board index */
   if( $this->registry->getClass('IPSAdCode')->userCanViewAds() )
   {
     $this->registry->getClass('IPSAdCode')->setGlobalCode( 'header', 'ad_code_forum_view_header' );
     $this->registry->getClass('IPSAdCode')->setGlobalCode( 'footer', 'ad_code_forum_view_footer' );
   }

заменяем его на ткой кодес:

    /* Set Ad code for the board index */
   if( $this->registry->getClass('IPSAdCode')->userCanViewAds() )
   {
     if ($this->forum['parent_id'] == 'root') {
       // category
       $fbanner = $this->DB->buildAndFetch( array( 'select' => 'banner', 'from' => 'forums', 'where' => "id=".$this->forum['id']) );
       if ($fbanner['banner']) $this->forum['banner'] = $fbanner['banner'];
     }
     if (strlen($this->forum['banner']) > 3) {
       $this->registry->getClass('IPSAdCode')->headerCode = $this->forum['banner'];
     } else {  
       $this->registry->getClass('IPSAdCode')->headerCode = $this->settings['ad_code_forum_view_header'];
     }
     $this->registry->getClass('IPSAdCode')->setGlobalCode( 'footer', 'ad_code_forum_view_footer' );
   }

 

Сохраняем файл /admin/applications/forums/modules_public/forums/forums.php и копируем его на WEB-сервер.

 

 

Открываем на редактирование файл /admin/applications/forums/modules_public/forums/topics.php и ищем следующий код:

    /* Set Ad code for the board index */
   if( $this->registry->getClass('IPSAdCode')->userCanViewAds() )
   {
     $this->registry->getClass('IPSAdCode')->setGlobalCode( 'header', 'ad_code_forum_view_header' );
     $this->registry->getClass('IPSAdCode')->setGlobalCode( 'footer', 'ad_code_forum_view_footer' );
   }

и заменяем его на такой кодес:

    /* Set Ad code for the board index */
   if( $this->registry->getClass('IPSAdCode')->userCanViewAds() )
   {
     if (strlen($this->forum['banner']) > 3) {
       $this->registry->getClass('IPSAdCode')->headerCode = $this->forum['banner'];
     } else {  
       $this->registry->getClass('IPSAdCode')->headerCode = $this->settings['ad_code_topic_view_header'];
     }      
     $this->registry->getClass('IPSAdCode')->setGlobalCode( 'footer', 'ad_code_topic_view_footer' );
   }

 

Сохраняем файл topics.php и копируем его на WEB-сервер.

 

 

Открываем на редактирование файл /admin/applications/forums/skin_cp/cp_skin_forums.php и ищем следующую строчку:

<li><label class='head'>{$this->lang->words['frm_f_basic']}</label></li>

Перед этой строкой нужно вставить следующие строчки:

<li><label class='head'>Header Banner</label></li>
<li>
 {$form['banner']}
</li>

 

Сохраняем файл cp_skin_forums.php и копируем его на WEB-сервер.

 

Все изменения внесены. Кеш обновлять не нужно.

 

В админке теперь видим новое поле для ввода (настройки конкретно форума):

sh_0009.png

 

В настройках категории новое поле тоже есть:

sh_0008.png

0 комментариев

Рекомендованные комментарии

Нет комментариев для отображения

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.