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

Reply
 
Thread Tools
Logo Rotation Details »»
Logo Rotation
Version: 0.7, by thunderclap82 thunderclap82 is offline
Developer Last Online: Apr 2019 Show Printable Version Email this Page

Category: Forum Display Enhancements - Version: 4.0.x Rating:
Released: 10-20-2010 Last Update: Never Installs: 22
Uses Plugins Template Edits
Re-useable Code Code Changes  
No support by the author.

I had a client who wanted a rotating logo system that allowed them to have fancy transitions and have each logo link to a specific page. No mod I could find allowed this so, utilizing a jQuery app called Nivo Slider, I've managed to create exactly what they wanted.

Please note that I've only attempted this with a fixed theme. I do not know how it will behave with a fluid one. If someone wants to test it and let me know I'll make changes to the instructions as necessary.

DEMO

Special Thanks: Lynne for helping me get the plug-in portion working properly.

Requirement: Nivo Slider

1. Download and decompress the Nivo Slider archive.
2. Upload the files jquery.nivo.slider.pack.js and nivo-slider.css to your forums 'clientscript' folder.
3. Go to vB AdminCP --> Plugins & Products --> Plugin Manager --> Add New Plugin. Enter the following information:

Product: vBulletin
Hook Location: template_register_var
Title: Nivo Logo Rotator
Execution Order: 5
Plugin PHP Code:

Code:
$templater = vB_Template::create('banner_rotator');
$templatevalues['banner_rotator'] = $templater->render();
vB_Template::preRegister('header', $templatevalues);
4. Save the Plugin.
5. Go to vB AdminCP --> Styles & Templates --> Style Manager --> Add New Template. Enter the following information:

Title: banner_rotator
Template:

Code:
<link rel="stylesheet" href="clientscript/nivo-slider.css" type="text/css" media="screen" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
<script src="clientscript/jquery.nivo.slider.pack.js" type="text/javascript"></script>

<div id="slider">
<a href="your URL"><img src="link to your image file" /></a>
</div>

<vb:literal>
<script type="text/javascript">
$(window).load(function() {
var total = $('#slider img').length;
var rand = Math.floor(Math.random()*total);
	$('#slider').nivoSlider({
		effect:'random',
		slices:15,
		animSpeed:500,
		pauseTime:7000,
                startSlide:rand,
		directionNav:false,
		directionNavHide:true,
		controlNav:false,
		controlNavThumbs:false,
                controlNavThumbsFromRel:false,
		keyboardNav:true,
		pauseOnHover:true,
		manualAdvance:false,
		captionOpacity:0.8,
		beforeChange: function(){},
		afterChange: function(){},
		slideshowEnd: function(){}
	});
});
</script>
</vb:literal>
(Note: There are a lot of customizations for Nivo here, so I suggest you looking over the official website to get an idea of what you can do. These settings change the logo every seven seconds or so. Also, with each new logo you can click on it and be taken to a different URL.)

6. Save.
7. Edit the additional.css template. Add at the bottom:

Code:
/* CSS for Banner_Rotator */
.banner_rotator
#slider {
	position:relative;
	background:url(images/loading.gif) no-repeat 50% 50%; 
}
#slider img {
	position:absolute;
	top:0px;
	left:0px;
	display:none;
}
#slider a{
	display:block;
}
8. Save.
9. Edit the header template. Find:

Code:
<div><a name="top" href="{vb:raw vboptions.forumhome}.php{vb:raw session.sessionurl_q}" class="logo-image"><img src="{vb:stylevar titleimage}" alt="{vb:rawphrase x_powered_by_vbulletin, {vb:raw vboptions.bbtitle}}" /></a></div>
Delete or comment it out, then replace add:

Code:
<div style="width:XXXpx; height:XXXpx;">
{vb:raw banner_rotator}
</div>
(Replace the "XXX" in width and height to that suite your graphic. Width might need a little extra room so experiment a bit.)

10. Save.

You should now have a rotating logo in the header of your vB forum.

Version History
0.7: Added code at step 9 to help lock the header dimensions for your logo.
0.6: Fixed IE bug
0.5: Initial Release

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #52  
Old 07-18-2012, 04:39 PM
Liff Liff is offline
 
Join Date: Aug 2011
Posts: 73
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by thunderclap82 View Post
Is the image a PNG? Nivo doesn't play nice with PNG so be sure to use JPG.
Nope.. It's deffo a .jpg

http://i46.tinypic.com/14vnxp5.jpg
Reply With Quote
  #53  
Old 07-18-2012, 05:40 PM
thunderclap82 thunderclap82 is offline
 
Join Date: Nov 2008
Posts: 305
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Liff View Post
Nope.. It's deffo a .jpg

http://i46.tinypic.com/14vnxp5.jpg
Can you use an image on your server instead? Maybe there is a problem with using tinypic.
Reply With Quote
  #54  
Old 07-21-2012, 08:37 PM
LgsOfChampions's Avatar
LgsOfChampions LgsOfChampions is offline
 
Join Date: Feb 2011
Location: Leagues Of Champions
Posts: 164
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

is this working for 4.2?
Reply With Quote
  #55  
Old 07-31-2012, 01:17 PM
Liff Liff is offline
 
Join Date: Aug 2011
Posts: 73
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by LgsOfChampions View Post
is this working for 4.2?
I've spent hours trying and failed miserably.

I would really appreciate it if anyone who has nailed this for 4.2 would mind sharing their success
Reply With Quote
  #56  
Old 07-31-2012, 06:21 PM
thunderclap82 thunderclap82 is offline
 
Join Date: Nov 2008
Posts: 305
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

While I don't really support the plug-in as I'm not a programmer by any means (had a lot of help from the community getting it working) I can say it does work with vB 4.2 PL1. That's what we run on our site and the plug-in works fine.
Reply With Quote
  #57  
Old 08-07-2012, 01:29 PM
Liff Liff is offline
 
Join Date: Aug 2011
Posts: 73
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by thunderclap82 View Post
While I don't really support the plug-in as I'm not a programmer by any means (had a lot of help from the community getting it working) I can say it does work with vB 4.2 PL1. That's what we run on our site and the plug-in works fine.
Tc.. I really like the plugin and while I can't get it to work I appreciate your support.

I've just started again from the very beginning and I have the exact same problem.

The problem for me seems still to be in the plugin as it kills my forum with the 503 error.

Can you confirm the details of the hook location as I've tried the two you've suggested to no avail. Everything else seems fine and it just looks as though it's waiting on the details of the banner rotator in order to work. If you want to see choose the Rotator TNT67 style on my forum: twistsnturns.net and you'll see what I mean. When I get it working I will be using it where my normal banner is, and not in the header, but I'll sort that once it's working

Thanks again for your time,

Liffey
Reply With Quote
  #58  
Old 08-07-2012, 07:08 PM
thunderclap82 thunderclap82 is offline
 
Join Date: Nov 2008
Posts: 305
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I run two sites and those are the took hook locations that work for me. It's possible another plug-in is causing a conflict. Not sure but, again, not a programmer so... *shrugs*

Not sure what else to tell you. Sorry.

Have you tried this mod?
Reply With Quote
  #59  
Old 08-08-2012, 07:49 AM
Liff Liff is offline
 
Join Date: Aug 2011
Posts: 73
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by thunderclap82 View Post
I run two sites and those are the took hook locations that work for me. It's possible another plug-in is causing a conflict. Not sure but, again, not a programmer so... *shrugs*

Not sure what else to tell you. Sorry.

Have you tried this mod?
Hey TC.. I know you're not a programmer but you have been a great help.

I'm kinda hoping someone else looking in might be able to explain what's going on.. I disabled a bunch of products I no longer use and got it working (Yay!) and then all of a sudden it stopped working in Chrome, but works fine in FF & Safari.

I've cleared my cache etc.., in Chrome but nothing...

Does anyone have any ideas as this is starting to drive me crazy

http://twistsnturns.net

Style: Slider TNT67
Reply With Quote
  #60  
Old 08-08-2012, 08:08 AM
Liff Liff is offline
 
Join Date: Aug 2011
Posts: 73
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

[Edit] I seem to be getting somewhere.. When I use the 'Parse_Templates' as hook location it works fine on the forum listing page, but not within the forum.

I understand TC might not be able to do this but is there any way to bypass the plug-in requirement of this modification in order to make it work regardless?

I do run a lot of mods on my forum and it's probable that one of them is clashing, but I'm very close to having this work and feel that just a little more and I'll be there

[Edit again] OK.. When I disable the parse_templates plug in modification for the Chiplove thumbnails it works fine.. The code for his is a little more complicated than the one for this modification and I would love to run both.. Does anyone have any ideas?

This is the code for the thumbnails hook in:

PHP Code:
#<?
if($vbulletin->options['chip_threadthumb_turn'] AND in_array(THIS_SCRIPT, array('forumdisplay', 'search')))
{
    function threadthumbnails_fetch_forums()
    {        
        global $vbulletin;
        list($w, $h) = explode(',', $vbulletin->options['chip_threadthumb_sizedefault']);        
        $lines = preg_split("#(\r\n|\r|\n)#", $vbulletin->options['chip_threadthumb_include']);
        if($vbulletin->options['chip_threadthumb_allforum'])
        {
            foreach( array_keys($vbulletin->forumcache) as $fid)
            {
                $vbulletin->forumcache[$fid]['thumb_w'] = $w;
                $vbulletin->forumcache[$fid]['thumb_h'] = $h;
            }
        }
        
        foreach($lines as $line)
        {
            list($fids, $w_h) = explode('|', $line);
            if($w_h)
            {
                list($w, $h) = array_map('intval', explode(',', $w_h));
            }
            $fids = array_map('intval', explode(',', $fids));
            foreach($fids as $fid)
            {
                if($vbulletin->forumcache[$fid])
                {
                    $vbulletin->forumcache[$fid]['thumb_w'] = $w;
                    $vbulletin->forumcache[$fid]['thumb_h'] = $h;
                }
            }
        }
        
        if ($exclude = explode(',', $vbulletin->options['chip_threadthumb_exclude']))
        {
            foreach($exclude as $fid)
            {
                if($vbulletin->forumcache[$fid]['thumb_w'])
                {
                    unset($vbulletin->forumcache[$fid]['thumb_w']);
                }
            }
        }    
        if ($exclude_groups = array_map('intval', explode(',', $vbulletin->options['chip_threadthumb_excludegroups'])))
        {
            if (in_array($vbulletin->userinfo['usergroupid'], $exclude_groups))
            {
                foreach( array_keys($vbulletin->forumcache) as $fid)
                {
                    unset($vbulletin->forumcache[$fid]['thumb_w']);
                }
            }
        }
    }
    function threadthumbnails_get_thumbnail($thread, $pagetext = '', $query = false)
    {
        global $vbulletin;        
        $thread['thumb'] = $pagetext ? $pagetext : $thread['pagetext'];
        $thread['thumb_src'] = '';
        
        $have_thumb = false;
        //using image of first post + youtube thumbnails
        if ( strpos($vbulletin->options['chip_threadthumb_types'], '1') !== false )
        {
            if (preg_match('#\[IMG\](.+?)\[\/IMG\]#i', $thread['thumb'], $m))
            {
                $thread['thumb_src'] = $m[1];    
                $have_thumb = true;
            }
            elseif (preg_match('#\[YOUTUBE\]([^\[]+?)\[\/YOUTUBE\]#i', $thread['thumb'], $m))    
            {
                $str = preg_replace('#(http.*watch\?v=)?([^"]+?)(&.*)?#', '$2', $m[1]);
                $thread['thumb_src'] = 'http://i4.ytimg.com/vi/'.$str.'/default.jpg';    
                $have_thumb = true;
            }
            elseif (preg_match('#\[video=youtube;([^\]]+?)\]#i', $thread['thumb'], $m)) 
            {
                $thread['thumb_src'] = 'http://i4.ytimg.com/vi/'.$m[1].'/default.jpg';    
                $have_thumb = true;
            }
        }
        //using file attach
        if ( 
            !$have_thumb // have not a thumbnails
            AND $thread['attach'] > 0 //have attach files
            AND (strpos($vbulletin->options['chip_threadthumb_types'], '2') !== false OR strpos($vbulletin->options['chip_threadthumb_types'], '3') !== false) )
        {
            //get attach file - image
            $attach = $vbulletin->db->query_first("
                SELECT attachment.attachmentid, attachment.dateline
                FROM ".TABLE_PREFIX."attachment AS attachment
                ".iif(strpos($vbulletin->options['chip_threadthumb_types'], '3') !== false, "
                    LEFT JOIN ".TABLE_PREFIX."filedata AS filedata ON (filedata.filedataid = attachment.filedataid)")."
                WHERE attachment.contentid = ".$thread['firstpostid']."
                    ".iif(strpos($vbulletin->options['chip_threadthumb_types'], '3') !== false, "AND filedata.extension IN ('png', 'jpg', 'jpeg', 'gif', 'bmp')")."
                LIMIT 1
            ");
            if($attach)
            {
                $thread['thumb_src'] = $vbulletin->options['bburl'].'/attachment.php?attachmentid='.$attach['attachmentid'].'&thumb=1&d='.$attach['dateline'];    
                $have_thumb = true;
            }
        }
        if($query AND !$have_thumb)
        {
            $post = $vbulletin->db->query_first("
                SELECT pagetext FROM ".TABLE_PREFIX."post WHERE threadid = $thread[threadid] AND parentid = 0 
            ");
            return threadthumbnails_get_thumbnail($thread, $post['pagetext']);
        }

        if(!$have_thumb AND $vbulletin->options['chip_threadthumb_useavatar'] AND ($thread['useavatar'] OR THIS_SCRIPT == 'search')) 
        {
            if(THIS_SCRIPT == 'search')
            {
                $useavatar = $vbulletin->db->query_first("
                    SELECT userid FROM ".TABLE_PREFIX."customavatar WHERE userid = ".$thread['postuserid']."
                ");
            }    
            if($useavatar OR $thread['useavatar'])
            {
                return $vbulletin->options['bburl'].'/image.php?' . $vbulletin->session->vars['sessionurl'] . "u=$thread[postuserid]";
            }
        }
        if (!$have_thumb)
        {
            $thread['thumb_src'] = vB_Template_Runtime::fetchStylevar("imgdir_misc").'/'.$vbulletin->options['chip_threadthumb_noimg'];    
        }
        return $thread['thumb_src'];
    }
    
    threadthumbnails_fetch_forums();
    
    
    if ($vbulletin->forumcache[intval($GLOBALS['forumid'])]['thumb_w'] > 0 OR THIS_SCRIPT == 'search')
    {        
        $template_name = iif(THIS_SCRIPT == 'search', 'search_').'threadbit';
        if($vbulletin->options['chip_threadthumb_zoom'])
        {        
            list($zoom_w, $zoom_h) = array_map('intval', explode(',', $vbulletin->options['chip_threadthumb_zoom_wh']));

        //add css
        $template_hook['headinclude_bottom_css'] .= '
<style type="text/css">
/* Chiplove.9xpro - Thread Thumbnails 2.2 */
#preview{position:absolute;border:1px solid #ccc;background:#333;padding:5px;display:none;color:#fff;}
</style>';

$jquery_lib = '';
if($vbulletin->options['chip_threadthumb_jquerypath'])
{
    if(substr($vbulletin->options['chip_threadthumb_jquerypath'], 0, 4) != 'http')
    {
        $jquery_lib = $vbulletin->options['bburl'].'/clientscript/jquery/'.$vbulletin->options['chip_threadthumb_jquerypath'];
    }
    else
    {
        $jquery_lib =& $vbulletin->options['chip_threadthumb_jquerypath']; 
    }
}

$template_hook['footer_javascript'] .= ($jquery_lib ? '<script type="text/javascript" src="'.$jquery_lib.'"></script>' : '').'
<script type="text/javascript">
/* Chiplove.9xpro - Thread Thumbnails 2.2 */
function imagePreview(){    
    xOffset = 30;
    yOffset = 30;
    jQuery("img.preview").hover(function(e){
        this.t = this.title;
        this.title = "";    
        var c = (this.t != "") ? "<br/>" + this.t : "";
        jQuery("body").append("<p id=\'preview\'><img src=\'"+ this.src +"\' style=\''.iif($zoom_w,"width:{$zoom_w}px;").iif($zoom_h,"width:{$zoom_h}px;").'\' alt=\'Image Preview\' />"+ c +"</p>");                                 
        jQuery("#preview")
            .css("top",(e.pageY - xOffset) + "px")
            .css("left",(e.pageX + yOffset) + "px")
            .fadeIn("fast");                        
    },
    function(){
        this.title = this.t;    
        jQuery("#preview").remove();
    });    
    jQuery("img.preview").mousemove(function(e){
        jQuery("#preview")
            .css("top",(e.pageY - xOffset) + "px")
            .css("left",(e.pageX + yOffset) + "px");
    });            
};
function removeTitle() {
    jQuery(".threadinfo").attr("title", "");
    jQuery(".threadstatus").attr("title", "");
    '.iif(THIS_SCRIPT == 'search', 'var items = jQuery("#searchbits").find(".threadbit");
    jQuery.each(items, function(k, v){
        if(typeof jQuery(items[k]).find("img.preview").attr("src") != "undefined") {
            jQuery(items[k]).find(".threadstatus").attr("title","");
            jQuery(items[k]).find(".threadinfo").attr("title","");
            jQuery(items[k]).find(".threadinfo").attr("title","");
            jQuery(items[k]).attr("title","");
        }
    });').'
}
jQuery(function(){
    imagePreview();
    setTimeout("removeTitle();", 1000);
});
</script>
';        
            $vbulletin->templatecache[$template_name] = str_replace(
                '<a class="title', 
                '<a title="\'.$thread[\'preview\'].\'" class="title', 
                $vbulletin->templatecache[$template_name]
            );
        }

        $vbulletin->templatecache[$template_name] = str_replace(
            '$final_rendered .= \'\' . \'></a>',
            '$final_rendered .= \'\' . iif($thread[\'thumb_src\'], \' style="height:\'.($vbulletin->forumcache[$thread[\'forumid\']][\'thumb_h\']+8).\'px !important;width:\'.($vbulletin->forumcache[$thread[\'forumid\']][\'thumb_w\']+10).\'px !important;'.$vbulletin->options['chip_threadthumb_cssforthumbnails'].iif(
            $vbulletin->options['chip_threadthumb_overwritestatus'], 'padding-left:'.$vbulletin->options['chip_threadthumb_overwritestatus'].'px;', 'background: none !important;'
            ).'">
                <!-- Forum using plugin: Thread Thumbnails 2.0 - Powered by chiplove.9xpro -->
                <img class="preview" src="\'.$thread[\'thumb_src\'].\'" style="width:\'.$vbulletin->forumcache[$thread[\'forumid\']][\'thumb_w\'].\'px;height:\'.$vbulletin->forumcache[$thread[\'forumid\']][\'thumb_h\'].\'px;border:1px solid #c8c8c8;background:#fff;padding:2px;display:block;"\').\' /></a>',
            $vbulletin->templatecache[$template_name]
        );
    }
}
Reply With Quote
  #61  
Old 12-10-2012, 05:27 PM
Dragonsys's Avatar
Dragonsys Dragonsys is offline
 
Join Date: Jan 2008
Location: DFW, Texas
Posts: 743
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

it is working well for me in parse_templates, on vB 4.2 pl3
You can see it here - http://www.lonestarcamaro.com/forums/
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 06:13 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.07148 seconds
  • Memory Usage 2,383KB
  • Queries Executed 26 (?)
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
  • (5)bbcode_code
  • (1)bbcode_php
  • (5)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (3)pagenav_pagelink
  • (11)post_thanks_box
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (11)postbit_onlinestatus
  • (11)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_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
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete