The only differences (visually) between what I've done here and what they have, is that I have not yet implemented anything to stay which category you are currently looking at (A feature I would like to get to, but not sure on the best implementation - any help on this would be greatly appreciated). The other difference is that they are using subSilver based style and i'm using prosilver.
I must ask that people DO NOT request code for subSilver based styles in any comment posted in this tutorial. As stated many time, I DO NOT provide any code for subSilver based styles, only prosilver. If anyone else wishes to post the code for subSilver, they are free to do so. You can even post your own tutorial - any topic posted in the Code Snippets forum, after approval, will be automatically added to the Articles section
I will say that while I may call this a "simple tutorial", it may be a bit advanced for some users. It requires you have a little knowledge about the phpBB template system and some basic javascript/css/html knowledge too.
Now that is out of the way, here is how you do it
Create a new file and call it "forumlist_body_tabs.html" and paste the contents of the following ode block into it. Upload it to your styles template folder. Now edit index_body.html and change
Comment:
to
- Code: Select all
<!-- INCLUDE forumlist_body.html -->
to
- Code: Select all
<!-- INCLUDE forumlist_body_tabs.html -->
The code below was made for a stick forumlist_body.html taken from phpBB 3.0.7-pl1
Comment:
forumlist_body_tabs.html
forumlist_body_tabs.html
- Code: Select all
<!-- DEFINE $CAT1 = 'General' --><!-- DEFINE $CAT2 = 'phpBB' --><!-- DEFINE $CAT3 = 'Test' --><!-- DEFINE $CAT4 = 'Private Forums' -->
<div id="tabs" style="margin: 20px 0 0 7px;">
<ul>
<li><a href="#" onclick="dE('l_cat1', 1); dE('l_cat2', -1); dE('l_cat3', -1); dE('l_cat4', -1); return false;"><span>{$CAT1}</span></a></li>
<li><a href="#" onclick="dE('l_cat1', -1); dE('l_cat2', 1); dE('l_cat3', -1); dE('l_cat4', -1); return false;"><span>{$CAT2}</span></a></li>
<li><a href="#" onclick="dE('l_cat1', -1); dE('l_cat2', -1); dE('l_cat3', 1); dE('l_cat4', -1); return false;"><span>{$CAT3}</span></a></li>
<li><a href="#" onclick="dE('l_cat1', -1); dE('l_cat2', -1); dE('l_cat3', -1); dE('l_cat4', 1); return false;"><span>{$CAT4}</span></a></li>
</ul>
</div>
<!-- BEGIN forumrow -->
<!-- IF (forumrow.S_IS_CAT and not forumrow.S_FIRST_ROW) or forumrow.S_NO_CAT -->
</ul>
<span class="corners-bottom"><span></span></span></div>
</div>
</div>
<!-- ENDIF -->
<!-- IF forumrow.S_IS_CAT or forumrow.S_FIRST_ROW or forumrow.S_NO_CAT -->
<div<!-- IF forumrow.FORUM_NAME eq $CAT1 --> id="l_cat1" style="display: block;"<!-- ENDIF --><!-- IF forumrow.FORUM_NAME eq $CAT2 --> id="l_cat2" style="display: none;"<!-- ENDIF --><!-- IF forumrow.FORUM_NAME eq $CAT3 --> id="l_cat3" style="display: none;"<!-- ENDIF --><!-- IF forumrow.FORUM_NAME eq $CAT4 --> id="l_cat4" style="display: none;"<!-- ENDIF -->>
<!-- ENDIF -->
<!-- IF forumrow.S_IS_CAT or forumrow.S_FIRST_ROW or forumrow.S_NO_CAT -->
<div class="forabg">
<div class="inner"><span class="corners-top"><span></span></span>
<ul class="topiclist">
<li class="header">
<dl class="icon">
<dt><!-- IF forumrow.S_IS_CAT --><a href="{forumrow.U_VIEWFORUM}">{forumrow.FORUM_NAME}</a><!-- ELSE -->{L_FORUM}<!-- ENDIF --></dt>
<dd class="topics">{L_TOPICS}</dd>
<dd class="posts">{L_POSTS}</dd>
<dd class="lastpost"><span>{L_LAST_POST}</span></dd>
</dl>
</li>
</ul>
<ul class="topiclist forums">
<!-- ENDIF -->
<!-- IF not forumrow.S_IS_CAT -->
<li class="row">
<dl class="icons">
<dt title="{forumrow.FORUM_FOLDER_IMG_ALT}">
<span class="forum-image">
<a href="{forumrow.U_VIEWFORUM}">
<!-- IF not forumrow.S_UNREAD_FORUM --><span class="forum-fade"><!-- ENDIF -->{forumrow.FORUM_IMAGE}<!-- IF not forumrow.S_UNREAD_FORUM --></span><!-- ENDIF -->
</a>
</span>
<!-- IF S_ENABLE_FEEDS and forumrow.S_FEED_ENABLED --><a class="feed-icon-forum" title="{L_FEED} - {forumrow.FORUM_NAME}" href="{U_FEED}?f={forumrow.FORUM_ID}"><img src="{T_THEME_PATH}/images/feed.gif" title="{L_FEED} - {forumrow.FORUM_NAME}" alt="{L_FEED} - {forumrow.FORUM_NAME}" /></a><!-- ENDIF -->
<a href="{forumrow.U_VIEWFORUM}" class="forumtitle">{forumrow.FORUM_NAME}</a><br />
{forumrow.FORUM_DESC}
<!-- IF forumrow.MODERATORS -->
<br /><strong>{forumrow.L_MODERATOR_STR}:</strong> {forumrow.MODERATORS}
<!-- ENDIF -->
<!-- IF forumrow.SUBFORUMS and forumrow.S_LIST_SUBFORUMS --><br /><strong>{forumrow.L_SUBFORUM_STR}</strong> {forumrow.SUBFORUMS}<!-- ENDIF -->
</dt>
<!-- IF forumrow.CLICKS and U_ACP -->
<dd class="redirect"><span>{L_REDIRECTS}: {forumrow.CLICKS}</span></dd>
<!-- ELSEIF not forumrow.S_IS_LINK -->
<dd class="topics">{forumrow.TOPICS} <dfn>{L_TOPICS}</dfn></dd>
<dd class="posts">{forumrow.POSTS} <dfn>{L_POSTS}</dfn></dd>
<dd class="lastpost"><span>
<!-- IF forumrow.U_UNAPPROVED_TOPICS --><a href="{forumrow.U_UNAPPROVED_TOPICS}">{UNAPPROVED_IMG}</a><!-- ENDIF -->
<!-- IF forumrow.LAST_POST_TIME --><dfn>{L_LAST_POST}</dfn>
<!-- IF not S_IS_BOT --><a href="{forumrow.U_LAST_POST}">{LAST_POST_IMG} {forumrow.LAST_POST_SUBJECT}</a><br /><!-- ENDIF -->
{L_POST_BY_AUTHOR} {forumrow.LAST_POSTER_FULL}
<br />{forumrow.LAST_POST_TIME}<!-- ELSE -->{L_NO_POSTS}<br /> <!-- ENDIF --></span>
</dd>
<!-- ENDIF -->
</dl>
</li>
<!-- ENDIF -->
<!-- IF forumrow.S_LAST_ROW -->
</ul>
<span class="corners-bottom"><span></span></span></div>
</div>
<!-- ENDIF -->
<!-- BEGINELSE -->
<div class="panel">
<div class="inner"><span class="corners-top"><span></span></span>
<strong>{L_NO_FORUMS}</strong>
<span class="corners-bottom"><span></span></span></div>
</div>
<!-- END forumrow -->
Let's break this down a little:
Each $CAT refers to the name of each category that you have. So for each category, create another $CATx (x would be just a number). The value of each $CAT must match exactly that of your category (ie. what you typed in the ACP).
Now, you'll notice that each of the tab links have an onclick set on them. This is where our javascript comes into play:
Comment:
- Code: Select all
onclick="dE('l_cat1', 1); dE('l_cat2', -1); dE('l_cat3', -1); dE('l_cat4', -1); return false;"
Setting an l_catx to 1 makes it visible and invisible if -1. My tutorial uses 4 categories, so if you have 5, you would add another <li> and onclick:
Comment:
- Code: Select all
<li><a href="#" onclick="dE('l_cat1', 1); dE('l_cat2', -1); dE('l_cat3', -1); dE('l_cat4', 1); dE('l_cat5', -1); return false;"><span>{$CAT5}</span></a></li>
This <div> further down does the check to see what id is active and sets the display accordingly:
Comment:
- Code: Select all
<div<!-- IF forumrow.FORUM_NAME eq $CAT1 --> id="l_cat1" style="display: block;"<!-- ENDIF --><!-- IF forumrow.FORUM_NAME eq $CAT2 --> id="l_cat2" style="display: none;"<!-- ENDIF --><!-- IF forumrow.FORUM_NAME eq $CAT3 --> id="l_cat3" style="display: none;"<!-- ENDIF --><!-- IF forumrow.FORUM_NAME eq $CAT4 --> id="l_cat4" style="display: none;"<!-- ENDIF -->>
Again, if you have more categories, add another line like this here and make sure to update all the id's
Comment:
- Code: Select all
<!-- IF forumrow.FORUM_NAME eq $CAT5 --> id="l_cat5" style="display: none;"<!-- ENDIF -->>
Lastly, you may have some categories that only certain groups can see. phpBB will handle the permission for forums and hide everything as normal, but you may not want to show a tab if they should not see it. This is the only real tricky part.
To hide a tab from guests, you can simply surround the tab like this:
Comment:
- Code: Select all
<!-- IF S_USER_LOGGED_IN --><li><a href="#" onclick="dE('l_cat1', 1); dE('l_cat2', -1); dE('l_cat3', -1); dE('l_cat4', -1); return false;"><span>{$CAT1}</span></a></li><!-- ENDIF -->
To show a tab only to moderators/admins:
Comment:
- Code: Select all
<!-- IF U_ACP or U_MCP --><li><a href="#" onclick="dE('l_cat1', 1); dE('l_cat2', -1); dE('l_cat3', -1); dE('l_cat4', -1); return false;"><span>{$CAT1}</span></a></li><!-- ENDIF -->
To hide for certain groups is a little more tricky. First you will need to install this little snippet. Now you can do something like this
Comment:
- Code: Select all
<!-- IF S_GROUP_X --><li><a href="#" onclick="dE('l_cat1', 1); dE('l_cat2', -1); dE('l_cat3', -1); dE('l_cat4', -1); return false;"><span>{$CAT1}</span></a></li><!-- ENDIF -->
Where X is the id of the group. You can add multiple groups to that as well.
I will agree that this is possibly not the best implementation, but the idea of it that it doesn't require any real core changes to your forum. In fact it's 1 new file and 1 template change. So you can easily port it to another template.
NB* This tutorial is not suited for forums that change the names of their categories often.
So far I have tested this the following styles and it works pretty well:
- prosilver
- proglass
- Revolution (inherits from prosilver)
- Supernova
- KSerious


