Go Back   vb.org Archive > vBulletin Modifications > vBulletin 5.x Modifications > vBulletin 5.x Template Modifications
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
[vBMods.rocks] Forum Category Spacing - no template editing needed/vBCloud compatible Details »»
[vBMods.rocks] Forum Category Spacing - no template editing needed/vBCloud compatible
Version: 1.00, by noypiscripter noypiscripter is offline
Developer Last Online: Sep 2023 Show Printable Version Email this Page

Category: Forum Home Enhancements - Version: 5.2.5 Rating:
Released: 12-20-2016 Last Update: Never Installs: 5
Supported
 

Want to separate or group forum categories in its own "table" without editing display_Forums_list template? The entire category and forum directory are displayed using a single <table> tag. This makes it impossible to separate the forums by category in its own table that has border without editing display_Forums_list template and adding multiple <table> tags as others had done. But not until now.

I thought that mod was great (and it is!) but it requires editing an existing template and most of you know that editing existing vBulletin templates is not recommended and ideal. So I got challenged to create my own version that doesn't require editing using pure CSS. But technically not really using pure CSS as I had no choice but to add a little bit of JavaScript in order to programmatically identify which is the last forum channel in a category. Knowing the last forum in a category enables the CSS to know where to break the table into multiple "tables". The end result is not using multiple actual <table> tags but with a little bit of creativity and imagination, I was able to replicate an illusion or impression of using multiple tables.

Without much further ado, here's how to accomplish this.

1. Add in css_additional template or via Sitebuilder (Edit Site ON) > Style > CSS Editor.

Code:
/* Forum Category Spacing START */
.l-xsmall .forum-list-container .forum-list-header {
    border: 0;
}
.l-xsmall .canvas-layout-container .canvas-widget .widget-header,
.l-xsmall #forum-tab .forum-list-container .forum-list-header th {
    border-top: 0;
}
.l-xsmall #forum-tab .forum-list-container .forum-list-header .header-forum {
    border-right: 1px solid #C9CED2;
}
#forum-tab.forum-category-spacing .category-header td {
    border-left: 1px solid #C9CED2;
    border-right: 1px solid #C9CED2;
}
#forum-tab.forum-category-spacing .forum-list-container {
    border-collapse: collapse;
}
#forum-tab.forum-category-spacing .forum-item .cell-forum,
#forum-tab.forum-category-spacing .subforum-list > td {
    border-left: 1px solid #C9CED2;
}
#forum-tab.forum-category-spacing .forum-item .lastpost,
#forum-tab.forum-category-spacing .subforum-list > td {
    border-right: 1px solid #C9CED2;
}
#forum-tab.forum-category-spacing .forum-item-last > td,
#forum-tab.forum-category-spacing .subforum-list table {
    position: relative;
    padding-bottom: 30px;
}
#forum-tab.forum-category-spacing .forum-item.forum-item-last .cell-forum,
#forum-tab.forum-category-spacing .subforum-list.forum-item-last > td {
    border-left: 0;
}
#forum-tab.forum-category-spacing .forum-item.forum-item-last .lastpost,
#forum-tab.forum-category-spacing .subforum-list.forum-item-last > td {
    border-right: 0;
}
#forum-tab.forum-category-spacing .forum-item-last .cell-forum:before {
    content: '';
    display: block;
    height: -webkit-calc(100% - 16px);
    height: calc(100% - 16px);
    width: 1px;
    position: absolute;
    top: 0;
    left: 0;
    background: #C9CED2;    
}
#forum-tab.forum-category-spacing .forum-item-last > td:after {
    content: '';
    display: block;
    height: 1px;
    width: 100%;
    position: absolute;
    bottom: 16px;
    background: #C9CED2;
}
#forum-tab.forum-category-spacing .forum-item-last .cell-forum:after {
    margin-left: -5px;
}
.l-small #forum-tab.forum-category-spacing .forum-item-last .cell-forum:after {
    margin-left: -25px;
}
.l-xsmall #forum-tab.forum-category-spacing .forum-item-last .cell-forum:after {
    margin-left: -10px;
}
#forum-tab.forum-category-spacing .forum-item-last .topics-count:after {
    margin-left: -15px;
}
#forum-tab.forum-category-spacing .forum-item-last .posts-count:after {
    margin-left: -7px;
}
#forum-tab.forum-category-spacing .forum-item-last .lastpost:after {
    margin-left: 0;
}
#forum-tab.forum-category-spacing .subforum-list.forum-item-last > td:after {
    margin-left: -29px;
}
#forum-tab.forum-category-spacing .forum-item-last .lastpost:before,
#forum-tab.forum-category-spacing .subforum-list.forum-item-last > td:before {
    content: '';
    display: block;
    height: -webkit-calc(100% - 16px);
    height: calc(100% - 16px);
    width: 1px;
    position: absolute;
    top: 0;
    right: -1px;
    background: #C9CED2;    
}
#forum-tab.forum-category-spacing .subforum-list.forum-item-last table {
    border-left: 1px solid #C9CED2;
    margin: -18px 0 -14px -29px;
}
#forum-tab.forum-category-spacing .subforum-list.forum-item-last table tr:first-child td {
    padding-top: 18px;
}
#forum-tab.forum-category-spacing .subforum-list.forum-item-last table td:first-child,
.l-small #forum-tab.forum-category-spacing .subforum-list.forum-item-last table td {
    padding-left: 29px;
}
.l-small #forum-tab.forum-category-spacing .subforum-list.forum-item-last table tr:first-child td + td {
    padding-top: 0;
}
#forum-tab.forum-category-spacing .subforum-list.forum-item-last table tr:last-child td,
.l-small #forum-tab.forum-category-spacing .subforum-list.forum-item-last table tr:last-child td:last-child {
    padding-bottom: 16px;
}
.l-small #forum-tab.forum-category-spacing .subforum-list.forum-item-last table tr:last-child td {
    padding-bottom: 0;
}
.l-xsmall #forum-tab.forum-category-spacing .forum-item:not(.forum-item-last) .cell-forum,
.l-xsmall #forum-tab.forum-category-spacing .forum-item-last .forum-wrapper, .forum-item-last .rx-forum-stats,
.l-xsmall #forum-tab.forum-category-spacing .forum-item-last .rx-lastpost-info {
    border-right: 1px solid #C9CED2;
}
.l-xsmall #forum-tab.forum-category-spacing .forum-item-last .forum-wrapper {
    margin-top: -8px;
    padding-top: 8px;
    display: block;
    padding-right: 10px;
}
.l-xsmall #forum-tab.forum-category-spacing .forum-item-last .rx-lastpost-info {
    margin-bottom: -14px;
    padding-bottom: 14px;
}
.l-xsmall #forum-tab.forum-category-spacing .forum-item-last .rx-forum-stats,
.l-xsmall #forum-tab.forum-category-spacing .forum-item-last .rx-lastpost-info {
    margin-right: -1px;
    padding-right: 10px;
    width: 100%;
}
#forum-tab.forum-category-spacing .list-footer {
    background: transparent;
    border-bottom: 0;
    margin-top: -10px;
}
/* Forum Category Spacing END */
NOTE: The border colors and spacing used above were based off the default vB5 style. You may need to tweak some values if you have a customized style/theme.


2. Add a script to dynamically determine the last forum in a category. Ideally, we should use a template hook to insert the script but unfortunately, there is no hook location that is close to the forum directory list. We need to run the script as soon as the forum directory is rendered to avoid flickering or flashing. I chose to add the script in the Mark Channels Read phrase which is right below the forum directory.
  • Go to AdminCP > Languages & Phrases > Search in Phrases.
  • Search for Mark Channels Read phrase
    • Search for text: mark_channels_read
    • Search in: Phrase Variable Name Only
  • In the English (US) Translation box, enter the following:

    Code:
    Mark Channels Read
    <script>
    (function() {
        var forumTab = document.getElementById('forum-tab'),
            categoryHeaders = forumTab && forumTab.querySelectorAll('.category-header'),
            forumItem,
            lastItem;
    
        if (categoryHeaders && categoryHeaders.length > 0) {
            for (var i = 0; i < categoryHeaders.length; i++) {
                forumItem = categoryHeaders[i].previousElementSibling;
                if (forumItem && (/\bforum-item|subforum\-list\b/i).test(forumItem.className)) {
                    forumItem.className += ' forum-item-last';
                }
            }
            lastItem = document.querySelector('#forum-tab > .forum-list-container > tbody > tr:last-child');
            lastItem && (lastItem.className += ' forum-item-last');
            forumTab.className += ' forum-category-spacing';
        }
    
    })();
    </script>
    NOTE: You can change Mark Channels Read with whatever phrase you want.
  • Save.

Compatibility:
  • Tested in vB 5.2.5 but this should work in older versions too.
  • Compatible with vBCloud.

Demo:
See homepage of my mod site at http://vbmods.rocks/

This mod is also posted at http://vbmods.rocks/forum/vbulletin-...oud-compatible

Enjoy!

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.
Благодарность от:
In Omnibus

Comments
  #2  
Old 12-21-2016, 06:50 PM
In Omnibus's Avatar
In Omnibus In Omnibus is offline
 
Join Date: Apr 2010
Location: Inside A Blade Server
Posts: 840
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I like it. It looks really clean from the image on your site.

How difficult would it be to make each "table" collapsible?
Reply With Quote
  #3  
Old 12-21-2016, 09:43 PM
noypiscripter's Avatar
noypiscripter noypiscripter is offline
 
Join Date: Jul 2013
Posts: 468
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I will look into it.
Reply With Quote
  #4  
Old 12-21-2016, 10:24 PM
noypiscripter's Avatar
noypiscripter noypiscripter is offline
 
Join Date: Jul 2013
Posts: 468
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Found a bug in the script. Updated the script in Step 2 in the first post. If you've already installed this mod, you have to update it.
Reply With Quote
  #5  
Old 10-15-2018, 09:59 AM
Hectorsky's Avatar
Hectorsky Hectorsky is offline
 
Join Date: Mar 2015
Posts: 175
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Got and issue with thise code, grid lines does not finish at the end of category, any advice?>
Reply With Quote
  #6  
Old 12-13-2021, 03:12 AM
Ghost Shadow's Avatar
Ghost Shadow Ghost Shadow is offline
 
Join Date: Aug 2005
Posts: 66
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Does not work on 4.2.5
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 08:37 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04054 seconds
  • Memory Usage 2,293KB
  • Queries Executed 22 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (2)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (6)post_thanks_box
  • (1)post_thanks_box_bit
  • (6)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (6)post_thanks_postbit_info
  • (5)postbit
  • (6)postbit_onlinestatus
  • (6)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete