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
(2016-09-17, 05:45 PM)aradabir007 Wrote: [ -> ]
(2016-09-17, 04:12 AM)izakgewdrick Wrote: [ -> ]$('#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.

Code:
 <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>

Ok so from what I can see, 
 <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>
Is the snippet we are looking at. Have you tried searching css for subforums? Subforum or forumbit? 
You can tell by the way the code is written, that divid=forumhome_forumbit_subforuns, that it refers back to css(or edit the theme xml). Its possible the links and titles can be edited there

I really don't know how and where to add this code:

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

Can you help me with that?

Think of it like this. If you do #index (maybe #home) its obvious where that is going to take you. So in this example, you could write #mycustomepage and as long as you have mycustompage.php in your dir, you will have no problems. Have you tried checking if subforums.php is actually there? It could well be as simple as not having a plural in it....
Pages: 1 2 3