MyBB Community Forums

Full Version: How do I hide Sub Forums if there isn't one?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
Hello,

Currently, my theme has subforums as dropdowns. See below.
[Image: 3YTxKGO.png]
The problem is when there is no subforums to show, it's still displaying the Sub Forums: menu and opening a blank dropdown when clicked. See below.
[Image: 189dSjY.png]

You can also check it out on the site http://139.59.146.117/index.php

Is it possible to remove Sub Forums: menu when there is no subforums? If so, how do I do that?

Thanks
admin control panel >> forums & Post

you can add, remove or edit (category, forum or sub forum)
(2016-09-12, 02:09 AM)ziuma Wrote: [ -> ]admin control panel >> forums & Post

you can add, remove or edit (category, forum or sub forum)

Thanks for the answer but as I already mentioned in the thread, it shows Sub Forums: menu even if there isn't one. So that's not possible to fix this by removing the subforum since it'll still display the Sub Forums: dropdown menu.
You should ask the theme creator for support, this does not happen with a default theme.
Assuming the dropdown is by jQuery : You have to modify the dropdown function with a conditional check.
I don't have your code so here is an example for you to guide if you can get the idea from it:

$('#subforum').click(function(){
    if($(this).children().length > 0){
       // Initiate Dropdown ...
    }
});

NB: If you wanna use commom class for multiple dropdowns instead of id : try ".closest('class_name')" method.
(2016-09-12, 11:49 AM)effone Wrote: [ -> ]Assuming the dropdown is by jQuery : You have to modify the dropdown function with a conditional check.
I don't have your code so here is an example for you to guide if you can get the idea from it:

$('#subforum').click(function(){
    if($(this).children().length > 0){
       // Initiate Dropdown ...
    }
});

NB: If you wanna use commom class for multiple dropdowns instead of id : try ".closest('class_name')" method.

I get it but I don't know how to apply this. So here is the code for the dropdown menu which is in the forumbit_depth2_forum template.

  <div class="forumhome_forum_bit" id="forum2">
        <div class="forumhome_forumbit_left" style="width: 100% !important; height: 100% !important;">
          <img src="images/bos.png" id="forum_statusicon_2">
          <a href="{$forum_url}">
            <span class="forumhome_forum_text">{$forum['name']}</span>
          </a>
        </div>
        <div class="forumhome_forumbit_right">

          <div id="forumhome_forumbit_subforums" class="hidden-xs hidden-sm">
            <a data-toggle="dropdown" href="#" role="button" aria-expanded="false">
              <span class="forumhome_subforum_text">{$lang->subforums}</span>
            </a>
            <ul class="forumhome_dropdown_menu dropdown-menu" role="menu">
				{$sub_forums}
            </ul>
          </div>


          <div id="forumhome_forumbit_lastpost">
           {$lastpost}
          </div>


        </div>
      </div>

This is the code that shows Sub Forums: menu. I guess it's not using jQuery, is it? The theme includes Bootstrap and using its dropdown feature. Can you help me with that?

(2016-09-12, 11:00 AM)Ashley1 Wrote: [ -> ]You should ask the theme creator for support, this does not happen with a default theme.

I can't because It was a custom made theme but the freelancer just ran away after he took the money and abandoned it. Undecided
What do you have in forumbit_subforums template ?

This whole div should be ideally be placed there, then subforums will only appear when there are subforums.

<div id="forumhome_forumbit_subforums" class="hidden-xs hidden-sm">
<a data-toggle="dropdown" href="#" role="button" aria-expanded="false">
<span class="forumhome_subforum_text">{$lang->subforums}</span>
</a>
<ul class="forumhome_dropdown_menu dropdown-menu" role="menu">
{$sub_forums}
</ul>
</div>
This is in the forumbit_subforums template:

<br />{$lang->subforums} {$sub_forums}
(2016-09-12, 10:32 PM)aradabir007 Wrote: [ -> ]
(2016-09-12, 11:49 AM)effone Wrote: [ -> ]Assuming the dropdown is by jQuery : You have to modify the dropdown function with a conditional check.
I don't have your code so here is an example for you to guide if you can get the idea from it:

$('#subforum').click(function(){
    if($(this).children().length > 0){
       // Initiate Dropdown ...
    }
});

NB: If you wanna use commom class for multiple dropdowns instead of id : try ".closest('class_name')" method.

I get it but I don't know how to apply this. So here is the code for the dropdown menu which is in the forumbit_depth2_forum template.

  <div class="forumhome_forum_bit" id="forum2">
        <div class="forumhome_forumbit_left" style="width: 100% !important; height: 100% !important;">
          <img src="images/bos.png" id="forum_statusicon_2">
          <a href="{$forum_url}">
            <span class="forumhome_forum_text">{$forum['name']}</span>
          </a>
        </div>
        <div class="forumhome_forumbit_right">

          <div id="forumhome_forumbit_subforums" class="hidden-xs hidden-sm">
            <a data-toggle="dropdown" href="#" role="button" aria-expanded="false">
              <span class="forumhome_subforum_text">{$lang->subforums}</span>
            </a>
            <ul class="forumhome_dropdown_menu dropdown-menu" role="menu">
				{$sub_forums}
            </ul>
          </div>


          <div id="forumhome_forumbit_lastpost">
           {$lastpost}
          </div>


        </div>
      </div>

This is the code that shows Sub Forums: menu. I guess it's not using jQuery, is it? The theme includes Bootstrap and using its dropdown feature. Can you help me with that?

(2016-09-12, 11:00 AM)Ashley1 Wrote: [ -> ]You should ask the theme creator for support, this does not happen with a default theme.

I can't because It was a custom made theme but the freelancer just ran away after he took the money and abandoned it. Undecided

My friend, I believe I have the answer you're looking for.  


<span class="forumhome_subforum_text">{$lang->subforums}</span>
</a>


Change that to this:

<span class="forumhome_subforum_text">&nbsp;</span>
</a>


This would display a blank space rather then the word Sub Forums.
To take this a step further, you could try running a search for the $subforums template.  Do you know how to do that?  And why don't you try learning how to build the template yourself?  It's actually quite easy and fun once you get the hang of it!
(2016-09-12, 11:01 PM)Ashley1 Wrote: [ -> ]What do you have in forumbit_subforums template ?

This whole div should be ideally be placed there, then subforums will only appear when there are subforums.

        <div id="forumhome_forumbit_subforums" class="hidden-xs hidden-sm">
          <a data-toggle="dropdown" href="#" role="button" aria-expanded="false">
            <span class="forumhome_subforum_text">{$lang->subforums}</span>
          </a>
          <ul class="forumhome_dropdown_menu dropdown-menu" role="menu">
               {$sub_forums}
          </ul>
        </div>

When I add this to forumbit_subforums, nothing happens

(2016-09-12, 11:17 PM)alfred702 Wrote: [ -> ]
(2016-09-12, 10:32 PM)aradabir007 Wrote: [ -> ]
(2016-09-12, 11:49 AM)effone Wrote: [ -> ]Assuming the dropdown is by jQuery : You have to modify the dropdown function with a conditional check.
I don't have your code so here is an example for you to guide if you can get the idea from it:

$('#subforum').click(function(){
    if($(this).children().length > 0){
       // Initiate Dropdown ...
    }
});

NB: If you wanna use commom class for multiple dropdowns instead of id : try ".closest('class_name')" method.

I get it but I don't know how to apply this. So here is the code for the dropdown menu which is in the forumbit_depth2_forum template.

  <div class="forumhome_forum_bit" id="forum2">
        <div class="forumhome_forumbit_left" style="width: 100% !important; height: 100% !important;">
          <img src="images/bos.png" id="forum_statusicon_2">
          <a href="{$forum_url}">
            <span class="forumhome_forum_text">{$forum['name']}</span>
          </a>
        </div>
        <div class="forumhome_forumbit_right">

          <div id="forumhome_forumbit_subforums" class="hidden-xs hidden-sm">
            <a data-toggle="dropdown" href="#" role="button" aria-expanded="false">
              <span class="forumhome_subforum_text">{$lang->subforums}</span>
            </a>
            <ul class="forumhome_dropdown_menu dropdown-menu" role="menu">
				{$sub_forums}
            </ul>
          </div>


          <div id="forumhome_forumbit_lastpost">
           {$lastpost}
          </div>


        </div>
      </div>

This is the code that shows Sub Forums: menu. I guess it's not using jQuery, is it? The theme includes Bootstrap and using its dropdown feature. Can you help me with that?

(2016-09-12, 11:00 AM)Ashley1 Wrote: [ -> ]You should ask the theme creator for support, this does not happen with a default theme.

I can't because It was a custom made theme but the freelancer just ran away after he took the money and abandoned it. Undecided

My friend, I believe I have the answer you're looking for.  


<span class="forumhome_subforum_text">{$lang->subforums}</span>
</a>


Change that to this:

<span class="forumhome_subforum_text">&nbsp;</span>
</a>


This would display a blank space rather then the word Sub Forums.
To take this a step further, you could try running a search for the $subforums template.  Do you know how to do that?  And why don't you try learning how to build the template yourself?  It's actually quite easy and fun once you get the hang of it!

This removed the Sub Forums: text even if there are subforums. So this didn't work. I don't know how to do that.
Pages: 1 2 3