How to exclude certain templates from displaying the widget

Discussion in '[bd] Widget Framework' started by planetzu, Dec 1, 2013.

  1. planetzu

    planetzu New Member

    I am using the following hook to run ads on my site:
    hook:ad_below_bottom_breadcrumb

    and using the following expression to show the ad only to unresitered users:
    Code:
    XenForo_Template_Helper_Core::callHelper('ismemberof', array($visitor,1))
    My question is: Is there a way to restrict the widget only to certain templates? I want it to load only for the 'thread pages' and not on 'profile pages' or 404 error pages for instance. Thank you.
     
  2. xfrocks

    xfrocks XenForo rocks!
    Staff Member

    Hi,

    For that hook position, you can use something like this

    PHP:
    XenForo_Template_Helper_Core::callHelper('ismemberof', array($visitor,1))
    AND 
    in_array($contentTemplate, array('thread_view''account_wrapper'))
     
  3. planetzu

    planetzu New Member

    Thanks a lot. Worked perfectly.
     
    xfrocks likes this.
  4. planetzu

    planetzu New Member

    Just wanted to add to the original question. Is it possible to not display the widget on certain threads using the 'thread ID'? Example, let's say I do not want the widget to appear on the following threads:

    sitename.com/threads/post-title.50
    sitename.com/threads/another-post-title.467

    How can I alter the above code to achieve this? Thank you!
     
    1. xfrocks

      xfrocks XenForo rocks!
      Staff Member

      xfrocks @planetzu If you use "thread_view" position, you can use this expression to prevent the widget from showing up
      PHP:
      !in_array($thread['thread_id'], array(50467))
       
      pete likes this.
      1
  5. planetzu

    planetzu New Member

    Great, thanks.
     
Loading...