XF 1.5 Hide node from list but content visible if URL known (guest only)

optrex

Well-known member
I would like to hide a forum node from displaying to guests, but have the content visible if the URL is known.

I would like the node visible to other usergroups, as per normal permissions, so un checking the tick box in the node "Display in the node list" is not an option.

I'm assuming this will be a template edit with a conditional, rather than a permission change - anyone able to supply me with a line of code as to what is needed please?
 
You may be able to achieve it by editing the node_list template and wrapping the foreach in a conditional statement checking for the node ID and guest status.
 
I've tried for this conditional as a wrapper

<xen:if is="{$visitor.user_id} AND !in_array({$node.node_id}, array(7, 8, 9, 10, 25))">

I was hoping to meet the criteria of this content will only show to logged in members, if it's not in node ID 7,8,9,10,25

If I remove the! It disappears for everyone. I'm now thinking I need an else with a definition of what to display tof members verses what guests see, but because the original template is a loop it's confusing me how to split the nodes I want to display from the nodes I don't.
 
My last attempt was
<xen:if is="{$visitor.user_id} AND !in_array({$node.node_id}, array(7, 10))">
<xen:foreach loop="$renderedNodes" value="$node">{xen:raw $node}</xen:foreach>

</xen:if>

but that hides all the nodes for guests, not just 7 and 10.

I've also tried CSS which works well using

.node_7 {
display: none;
}

Until I try to add a conditional, to make it just work for guests, then I get stuck because the CSS templates wont accept this conditional.
 
OMFG. 4 days on this and I can't believe how simple this was in the end. Add the following to extra.css

.LoggedOut .node_7
{
display: none;
}
 
Top Bottom