I have this code in the settings
{{if request.app == 'forums' and request.module == 'forums' and request.controller == 'topic'}}
{{$topic = \IPS\Output::i()->hiddenElements['nbenhadverts_item_item'];}}
{{if $topic and $topic->topic_meta_data == 2}}
1
{{endif}}
{{endif}}
so it checks the topic_meta_data field in the topics table and if the value is 2 shows the ad code. While sometimes it works, there are many topics where the value is 2 and the ad code is now showing in the html.
Thank you