exclude nodes from hook listner

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 :

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

 if($visitor->isMemberOf($user_group_id))
{
.
.
.

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

Thanks in advance for any assistance.
 
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))
 
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))

Just what I needed, thank you. That just opened another door for me in my learning. :)
 
Last edited:
Back
Top Bottom