Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Content Management System (http://www.go4expert.com/articles/cms/)
-   -   Convert vBulletin Blog Categories into Global Categories. (http://www.go4expert.com/articles/convert-vbulletin-blog-categories-t14280/)

shabbir 30Sep2008 18:52

Convert vBulletin Blog Categories into Global Categories.
 
1 Attachment(s)

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

shabbir 1Oct2008 11:28

Re: Convert vBulletin Blog Categories into Global Categories.
 
Just forgot to mention that you can see the working example of it at www.mbaguys.net

shabbir 2Oct2008 21:41

Re: Convert vBulletin Blog Categories into Global Categories.
 
Nominated for article of the month for September 2008

seoblogcentral01 9May2009 12:31

Re: Convert vBulletin Blog Categories into Global Categories.
 
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,

lovesorrow1102 19Aug2009 14:08

Re: Convert vBulletin Blog Categories into Global Categories.
 
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.:(


All times are GMT +5.5. The time now is 20:11.