Invision Community 4: SEO, prepare for v5 and dormant account notifications By Matt Monday at 02:04 PM
virap1 Posted September 13, 2022 Posted September 13, 2022 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}}
virap1 Posted September 15, 2022 Author Posted September 15, 2022 I would really appreciate if someone knows why the above template code is not working.
Daniel F Posted September 15, 2022 Posted September 15, 2022 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. SeNioR- 1
virap1 Posted September 15, 2022 Author Posted September 15, 2022 Thank you Daniel. Yes, i need a conditional that would work both for forums and topics. Could you help me modify it accordingly if possible?
virap1 Posted September 17, 2022 Author Posted September 17, 2022 @Daniel F, anyone? How do I fix this conditional?
Recommended Posts