XF 2.2 hide subforums with CSS

Tamasita

Member
How could I hide all the subforums in a specific forum with CSS? Using the control panel and unticking "Display in the node list" is not good because it hides data from the thread and message counter too.

I have already tried this code below in extra.less. When I put the node ID, it does not work, but without the node ID it works, but then it hides my nodes from everywhere. How could I specify only one node?"



.node.node--id1181 .block-body .node {
display: none;
}
 
Solution
I'd probably approach it as a two-part edit:

Open the template forum_view
Just below this:
Code:
<xf:ad position="forum_view_above_node_list" arg-forum="{$forum}" />
on Line 32, change:
Code:
<div class="block">
to:
Code:
<div class="block block-subforums">

Then add your CSS, replacing 3 with whatever node id you're viewing.
Code:
[data-container-key="node-3"] .block.block-subforums {
    display: none;
}

You could use just CSS but this is potentially a little less problematic.
So this CSS would hide the sub-forum dropdown on the forum index for a specific node:

Code:
.node--id1181 .node-subNodeMenu {
    display: none;
}

Or if you have the sub-forum's not in a drop down but inline:
Code:
.node--id1181 .node-subNodesFlat {
    display: none;
}
 
"Thank you
So this CSS would hide the sub-forum dropdown on the forum index for a specific node:

Code:
.node--id1181 .node-subNodeMenu {
    display: none;
}

Or if you have the sub-forum's not in a drop down but inline:
Code:
.node--id1181 .node-subNodesFlat {
    display: none;
}

Thank you for your comment. Unfortunately, none of them works for me. It might not have been clear, but I need to hide the subforums that are above the threads in a forum."

screeenshot.webp
 
I'd probably approach it as a two-part edit:

Open the template forum_view
Just below this:
Code:
<xf:ad position="forum_view_above_node_list" arg-forum="{$forum}" />
on Line 32, change:
Code:
<div class="block">
to:
Code:
<div class="block block-subforums">

Then add your CSS, replacing 3 with whatever node id you're viewing.
Code:
[data-container-key="node-3"] .block.block-subforums {
    display: none;
}

You could use just CSS but this is potentially a little less problematic.
 
Last edited:
Solution
I'd probably approach it as a two-part edit:

Open the template forum_view
Line 32, add an extra class:

Code:
    <xf:ad position="forum_view_above_node_list" arg-forum="{$forum}" />
    <div class="block block-subforums">
the "block-subforums" bit.

Then add your CSS, replacing 3 with whatever node id you're viewing.
Code:
[data-container-key="node-3"] .block.block-subforums {
    display: none;
}

You could use just CSS but this is potentially a little less problematic.

Yes, thank you very much, it does the job well. I just had to add an extra </div> too after the 42nd line.

screen1.webp

screen2.webp
 
I'd undo that change, it'll probably add extra spacing when not hidden with your approach. I meant add the block-subforums to the existing line there:

change:

Code:
 <div class="block">

to:
Code:
 <div class="block block-subforums">

I edited my original post to make it clearer.
 
I'd undo that change, it'll probably add extra spacing when not hidden with your approach. I meant add the block-subforums to the existing line there:

change:

Code:
 <div class="block">

to:
Code:
 <div class="block block-subforums">

I edited my original post to make it clearer.

Oh yes, I misunderstood you. Thanks for making it clear. I fixed my code to remove the extra spacing
screen3.webp
 
Back
Top Bottom