MyBB Community Forums

Full Version: Get {$forum['fid']} at the index templates
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
In the index, forums are grouped as a whole. {$forum['fid']} would have no logical value. I would honestly just go with the solution you have, it may be hacky, but I think there is no other way.
(2013-03-28, 10:48 PM)Seabody Wrote: [ -> ]In the index, forums are grouped as a whole. {$forum['fid']} would have no logical value. I would honestly just go with the solution you have, it may be hacky, but I think there is no other way.

So , I should not move the javascript code to the index? If in the further, I have a lots of categories, then a lots of javascript code will come together.

A lots of javascript will slow down the forums, what shoud I do now ?
You have two options that I can see. Smile

A) Nothing
B) Hardcode the values into the headerinclude template so that the entire JS is called once. For example (highly simplified):

Instead of this:
<script>
$("#forum-{$forum['fid']}").click()
{
// Hide the children
}
</script>
Do this:
<script>
$("#forum-1").click()
{
$("#forum-2").hide();
}
</script>
So, with this code :

<a id="cat_{$forum['fid']}" href="javascript:;" class="forum-parent">{$forum['name']}</a>
<div class="child-forums" id="cat_{$forum['fid']}_e" style="{$expdisplay}">
<div class="forums-list">
{$sub_forums}
</div> <!-- /end forums-list -->
</div> <!-- /end child-forums -->
<span class="clear"></span>

I need to call in headerinclude like this

<script>
$("#cat_{$forum['fid']}").click() {
$("#cat_{$forum['fid']}_e").hide();
}
</script>


Right ?

P/S:

I tried call {$forum['fid']} in the headerinclude but ... Sad It still undefined
Nope. Let's assume that, for example, when you clicked on forum id 11, then forum ids 14 and 12 would be hidden. You would do this:

<script>
$("#cat_11").click() {
$("#cat_14_e").hide();
$("#cat_12_e").hide();
}
</script>
So, if I added new category. I need to modify this script right ?

Is there really no way to get {$forum['fid']} in index.php (index templates) or global.php (header, footer templates) ?

Any updates?
(2013-03-30, 02:43 PM)LCTG Wrote: [ -> ]So, if I added new category. I need to modify this script right ?

Is there really no way to get {$forum['fid']} in index.php (index templates) or global.php (header, footer templates) ?


Any updates?

My apologies for bumping an old thread, but I need the exact same thing.

I even made a thread in Plugin Development, asking for the same thing.

So like LCTG said, is there a way to get $forum['fid'] in the header template?
Pages: 1 2