Convert vBulletin Blog Categories into Global Categories.

shabbir's Avatar author of Convert vBulletin Blog Categories into Global Categories.
This is an article on Convert vBulletin Blog Categories into Global Categories. in Content Management System.
Rated 4.88 By 8 users

Introduction



I just purchased new vBulletin blog and as always its very well coded but I guess when I any forum owner buys vBulletin blog his

aim is not to create an individual blog but make it Global Blog for the forums. At least I had such a requirement and so here is

an hack to do it. I am posting it here because I have not seen any hacks for the blog.

Background



I have created it such that every one has access to only categories created by me i.e. userid = 1 and if you would like this to

be different from 1 make changes accordingly in the code changes below.

First import the product using Admin CP > Plugins& Products > Manage Products > Add Import product . Also this involves

additional code as well as template changes and so I would list them here.

File : /includes/blog_functions.php
Find
PHP Code:
    $cats $vbulletin->db->query_read_slave("
        SELECT blog_category.*
        FROM " 
TABLE_PREFIX "blog_category AS blog_category
        WHERE userid = 
$userid
        ORDER BY displayorder
    " 
Comment the above and replace it with the below one.
PHP Code:
    $cats $vbulletin->db->query_read_slave("
        SELECT blog_category.*
        FROM " 
TABLE_PREFIX "blog_category AS blog_category
        WHERE userid = 1
        ORDER BY displayorder
    " 
Find
PHP Code:
function &build_overview_sidebar($month 0$year 0)
{
    global 
$vbulletin$show$stylevar$vbphrase$vbcollapse
Add the global variable $sidebar to the list.
PHP Code:
function &build_overview_sidebar($month 0$year 0)
{
    global 
$vbulletin$show$stylevar$vbphrase$vbcollapse$sidebar
File : blog.php
Find

PHP Code:
else if (!empty($_REQUEST['userid']) OR !empty($_REQUEST['u']) OR !empty($_REQUEST['username'])) 
and replace with
PHP Code:
else if (!empty($_REQUEST['userid']) OR !empty($_REQUEST['u']) OR !empty($_REQUEST['username']) OR !empty($_REQUEST['blogcategoryid'])) 
In short add the following condition
PHP Code:
OR !empty($_REQUEST['blogcategoryid']) 
Now add the following lines into the blog_sidebar_generic template
HTML Code:
	<if condition="$sidebar['categorybits']">
		<div class="tborder" style="margin-top:$stylevar[cellpadding]px; padding:$stylevar[cellspacing]px">
			<div class="thead" style="padding:$stylevar[cellpadding]px">
				<a style="float:$stylevar[right]" href="#top" onclick="return toggle_collapse('blog_categories')"><img id="collapseimg_blog_categories" src="$stylevar[imgdir_button]/collapse_thead$vbcollapse[collapseimg_blog_categories].gif" alt="" border="0" /></a>
				$vbphrase[blog_categories]
			</div>
			<div class="alt1 smallfont" style="padding:$stylevar[cellpadding]px; margin-top:$stylevar[cellspacing]px; $vbcollapse[collapseobj_blog_categories]" id="collapseobj_blog_categories">
				<ul style="list-style:none; padding:0px; margin:0px">$sidebar[categorybits]</ul>
			</div>
		</div>
	</if>
If you would like your user not to be able to add new categories

File : blog_usercp.php
Find
PHP Code:
if ($_POST['do'] == 'updatecat')

and below that add
PHP Code:
    // Edit the user id to the userid who should be able to create the categories. This is same id for which you are fetching the categories
    
if($vbulletin->userinfo['userid'] != 1
    {
        
print_no_permission();
    } 
All done
Attached Files
File Type: zip product-blog_global_category.zip (1.1 KB, 9 views)
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Just forgot to mention that you can see the working example of it at www.mbaguys.net
Friends,
Its wonderful concept as well as very essential for vbulletin blog users.Its good news for all vbulletin forum users and we are waiting for next build release. sure.. this upgrade will control the spam users and will give the best look and feel option.


Thanks,

Last edited by shabbir; 9May2009 at 20:07.. Reason: Confine links to signatures only
lovesorrow1102's Avatar, Join Date: Aug 2009
Newbie Member
Thank you for providing us with the example code, and a brief explanation of the problem. However, we do not fully understand the problem you are experiencing.