Back to vBulletin 4.x Template Modifications

Sidebar Anywhere Enhancement - Custom Blocks Per Forum or Page
Mod Version: 1.00, by addamroy

vB Version: 4.1.x Rating: (1 vote - 5.00 average) Installs: 11
Released: 14 Mar 2013 Last Update: Never Downloads: 0
Not Supported Template Edits Re-usable Code Translations  

I came up with this after downloading and installing the Sidebar Anywhere by BOP5 mod.

I didn't get permission from him or anyone to post this here, I hope the title isn't a big deal it's just a template mod I made up that allowed me to further build upon the features that mod made possible.

That MOD in a nutshell lets you display your forum sidebar on any or all pages of your forum. ie forumdisplay pages, showthread pages, profile pages, etc.

The problem was the sidebar was the exact same on each page, there is no way to show one block here, and a different block there, while keeping the sidebar on the homepage the same. Basically I wanted to create 'different sidebars' on the various forum pages.

Well unfortunately with the way vbulletin works, manual template edits could only get me so far but this DOES give me new options to work with.

Here's what is accomplish with this:

1 - Display the standard sidebar blocks on your HOMEPAGE only. ie the Forum Threads, Forum Posts, Group Discussions, and Tag Cloud blocks.

2 - Create any number of Custom HTML/PHP blocks that only show in certain forums or on certain pages, etc.

Essentially what's happening here, is your main sidebar stays the same on your homepage and remains unaffected, HOWEVER you will have the ability to create new custom sidebars on any forum pages using Custom HTML/PHP blocks.

You could display certain advertisements, sponsors, links, graphics etc in certain sections giving you the ability to further customize your forum utilizing the Sidebar Anywhere mod by BOP5.

Instructions:
Edit your default block_ templates. Styles & Templates > Style Manager > Your Style > Edit Templates > Block_Templates

You need to ADD the following code bits to the TOP AND BOTTOM of each of the following block templates (block_newposts, block_threads, block_tagcloud, block_sgdiscussions)

Add to the very TOP of each template:
Code:
<vb:if condition="THIS_SCRIPT == 'index'">
Add to the very BOTTOM of each template:
Code:
</vb:if>
This will restrict the main forum sidebar blocks to your forum's homepage (index page), change 'index' to suit your needs if your forum is modified as such.

Create a new template with conditionals FOR EACH block you'd like to create that displays only in certain sections, on certain pages, to certain usergroups etc.

STEP 1 - Copy the contents of your block_html template

STEP 2 - Create a new template. Style Manager > Your Style > Add New Template

In the title field, call it block_html_SOMETHINGHERE replace SOMETHINGHERE with an identifier you choose. For example if you want this block to show only in your classifieds section if you have one, you might call your template block_html_classifieds

In the template field, paste the copied content from your existing block_html template from step 1.

BEFORE YOU SAVE THE TEMPLATE, do step 3.

STEP 3 - This is where the magic happens, we're going to simply wrap conditionals around everything to display the block where you want it, and to who you want.

At the very TOP you will add your opening conditionals.
For the sake of example, we will show this block only in a certain forum, and only to guests. (Your classifieds section maybe)

At the very TOP of this new template, ADD the following code:
Code:
<vb:if condition="$GLOBALS[forumid] == xx">
<vb:if condition="$show['guest']">
Replace xx with the forumid of the forum you want to display this block in.

At the very BOTTOM of this new template, ADD the following code:
Code:
</vb:if>
</vb:if>
Save your new template now.

STEP 4 - Add your new Block to the Sidebar. Forums & Moderators > Forum Blocks Manager > Add Block

Use block type: Custom HTML/PHP

Enter the content of your new custom block as you normally would.

In the "Template To Use" field at the bottom of the new block page, enter the name of the template you created in step 2 and 3. ie in this example, we would enter block_html_classifieds here

Save the block.

That's it! This new block will display only in the forum you selected and to guests.

For a larger list of conditionals you can play around with to really get your sidebar(s) going there is a good list here
http://www.forumthemes.com/helpful-tips-tricks-articles/1808-vbulletin-4-template-conditionals-list.html

It's a 4 step process per forum block you want to add. You could always use a conditional to show the block on every page EXCEPT the homepage, or every forum EXCEPT one or two, etc etc.

If any section of the forum doesn't have any sidebar blocks that will display there, even with the Sidebar Anywhere mod activated, no sidebar will be shown at all and the page will be unaffected .

I hope this helps some of you! If I was better at coding I'd like to be able to include instructions for conditionalizing the forum posts, forum threads, tag cloud and discussions blocks to use with sidebar anywhere, unfortunately the Custom HTML/PHP block is the only one reasonably easy to customize as needed because it gives you the option to utilize a specific template we create.

Check out my other Template Modifications for 4.x!

[Postbit-Legacy Hack] Attractive User Info Boxes for Posts

http://www.vbulletin.org/forum/showthread.php?p=2393460

Change Thread Title Color for Specific Forums on Homepage

Change Background Color for Specific Forums on Homepage

Change Title Color of Specific Forums on Homepage

Thread Starter Image in Postbit for OP

CUSTOM BUTTONS that look like your forum!

Custom User Rank Box in Posts

Download

No files for download.


vblts.ru supports vBulletin®, 2022-2024