MyBB Community Forums

Full Version: How to show some text, only for a specific FID Category and it's children Categories?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Let's say I wanted to show some text in the header of my forum, but only for a specific FID Forum Category, and all of it's Children categories.

What code would allow me to do that?
where you want to show that text.. on the index page inside a category or on the forumdisplay page... you can use PHP in Templates plugin to do it...
(2014-12-05, 07:06 AM)mmadhankumar Wrote: [ -> ]where you want to show that text.. on the index page inside a category or on the forumdisplay page... you can use PHP in Templates plugin to do it...

I know I will use PHP. But I need to know the actual code that will allow me to do it.

Something like "if forum id == 5 && if child/subchild/subsubchild/etc of forum id 5 then, display this text".
The easiest would be to use template conditionals; its actually a nice way to use some basic commands that will help later with coding a plugin etc.

For what you want, I would use an array.


The naming of the fids is not consistent across MyBB, so it does depend where you want to show it.

For index:

<if in_array($forum['fid'], array(1,2,3)) then>SHOW IT</if>

where the numbers in brackets (1,2,3) are the numbers of the forums.
(2014-12-05, 10:51 AM)Leefish Wrote: [ -> ]The easiest would be to use template conditionals; its actually a nice way to use some basic commands that will help later with coding a plugin etc.

For what you want, I would use an array.


The naming of the fids is not consistent across MyBB, so it does depend where you want to show it.

For index:


<if in_array($forum['fid'], array(1,2,3)) then>SHOW IT</if>

where the numbers in brackets (1,2,3)  are the numbers of the forums.

How could the code be modified to also show in all child/grandchild/greatgrandchild/etc of the forum ID?
You just add the numbers of the forums between the brackets. That is why I suggested an array rather than a list of ifs. If you want to find them all programmatically then you need to edit the core files or write a plugin.
Surely a built in MyBB function exists that can show all child/grandchild/greatgrandchild/etc elements of a MyBB Forum Category, doesn't it?