Skip to content

Из темы узнать ID подфорума

Раньше в тройке размещал рекламу в произвольном месте в зависимости от подфорума.

Сейчас пытаюсь тоже самое разместить в 4.1, но не выходит.

В самом подфоруме в списке тем могу достать ID подфорума, а вот в самой теме этого подофорума - нет.

Вот мой код:

{{if request.app='forums' and request.module ='forums' and request.controller ='forums'}}
 {{if request.id == 91 OR request.id == 114}}{advertisement="MY_ADV_PLACE"}
 {{else}}{advertisement="ad_global_header"}
 {{endif}}
{{endif}}

Вопрос - как в самой теме вытащить ID подфорума?

Featured Replies

Шаблон какой?

Кстати первая строка у Вас не корректна.

{{if request.app='forums' and request.module ='forums' and request.controller ='forums'}}

Должно быть по 2 знака =

  • Author

Шаблон GlobalTemplate

В нем нет нужных данных.

Можно через тему

{{if request.app == 'forums' and request.module == 'forums' and request.controller == 'topic' and request.id}}
{{ $fid = null; try { $topic = \IPS\forums\Topic::loadAndCheckPerms(request.id); $fid = $topic->container()->_id; } catch(\Exception $e){} }}
{{if in_array($fid, array(91, 114))}}
	{advertisement="MY_ADV_PLACE"}
{{else}}
	{advertisement="ad_global_header"}
{{endif}}
{{endif}}

  • Author

Это для какого шаблона? В GlobalTemplate не работает данный код

Это для какого шаблона?

Для какого просили.

В GlobalTemplate не работает данный код

Что выводится? И выводится ли вообще? Объявления созданы? В теме смотрите результат?

Попробуйте с числами

{{if request.app == 'forums' and request.module == 'forums' and request.controller == 'topic' and request.id}}
   {{ $fid = null; try { $topic = \IPS\forums\Topic::loadAndCheckPerms(request.id); $fid = $topic->container()->_id; } catch(\Exception $e){} }}
   {{if in_array($fid, array(91, 114))}}
       123
   {{else}}
       321
   {{endif}}
{{endif}}

  • Author

Сори тупанул. Все разобрался.

В общем вот мой конечный код, чтобы и в разделах и в темах показывался баннер:

{{if request.app == 'forums' and request.module == 'forums' and request.controller == 'topic' and request.id}}
   {{ $fid = null; try { $topic = \IPS\forums\Topic::loadAndCheckPerms(request.id); $fid = $topic->container()->_id; } catch(\Exception $e){} }}
   {{if in_array($fid, array(91, 114))}}
       {advertisement="MY_ADV_PLACE"}
   {{else}}
       {advertisement="ad_global_header"}
   {{endif}}
{{elseif request.app=='forums' and request.module == 'forums' and request.controller == 'forums'}}
 {{if request.id == 91 OR request.id == 114}}{advertisement="MY_ADV_PLACE"}
 {{else}}{advertisement="ad_global_header"}
 {{endif}}      
{{else}}{advertisement="ad_global_header"}                      
{{endif}}

Create an account or sign in to comment

Account

Navigation

Search

Search

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.