1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

exclude nodes from hook listner

Discussion in 'XenForo Development Discussions' started by SimonV, Jan 24, 2015.

  1. SimonV

    SimonV Well-Known Member

    I'm trying to teach myself this stuff so its slow going, most things I've figured out from other posts here or looked at how other add-ons do things. But I'm stuck on what I want to do next.

    I want to exclude nodes from including a template via a hook, I have my listener setup and working and my template includes just fine in the hook "thread_view_pagenav_before".

    I also have an admin option with an array callback that gets my nodes and stores them just fine. Now I'm stuck at how to use that stored admin option array of node ids to exclude my template being included.

    I figured it out to if I wanted to include certain usergroups with a similar setup I could do something along the line of :

    $visitor XenForo_Visitor::getInstance();
    $xenoptions XenForo_Application::get('options');
    $user_group_id $xenoptions->adminoptionid;

    But I'm completely stuck with the node id type scenario.

    Thanks in advance for any assistance.
  2. Syndol

    Syndol Guest

    In your hook function fetch the thread param and compare the node ID to your array of node Ids:
    $thread = $template->getParam('thread');
    if (in_array($thread['node_id'], $myNodeIds))
    Steve F and SimonV like this.
  3. SimonV

    SimonV Well-Known Member

    Just what I needed, thank you. That just opened another door for me in my learning. :)
    Last edited: Jan 25, 2015
    Syndol likes this.

Share This Page