Jump to content

Template conditional for forum id


Recommended Posts

Hello. I am trying to display a meta tag based on the forum id. But this code placed in the global template does not work. 

Could someone help me to understand what is wrong with the template code.

Thank you.

{{if request.app == 'forums' && request.module == 'forums' && in_array(request.id, array(24, 31, 46) )}}
<meta name="ezoicnoads" content="members">
{{endif}}


 

Link to comment
Share on other sites

Try 

{{if \IPS\Dispatcher::i()->application->directory == 'forums' and \IPS\Dispatcher::i()->module and \IPS\Dispatcher::i()->module->key == 'forums' AND \IPS\Dispatcher::i()->controller == 'forums' AND \in_array(\IPS\Request::i()->id, [24, 31, 46] )}}
will be only shown on the forum page for forum 24, 31, 46
{{endif}}

 

BUT this is ONLY for the forum view and not topics!

You'll need another condition for the topic controller which takes the topic to get the forum id for the in_array check if you want need this also inside topics.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...