The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
[vB4] Using Plugins for Template Edits
When I started out editing my own vBulletin forum, everything I changed was done using the additional.css template and manually editing templates. Once I started adding a few more styles/themes to my forum, things became stressful as I would then have to make all those edits again. A pain in the backside! So I decided to start looking into making plugins to do the work for me. One plugin = all styles updated. Simple! I will say that I knew how to use the addon "Firebug" for Firefox which makes it a lot easier to find the ID's and Class's of each item you want to change on your forum. It was a long process to learn what to put in the plugin, what hook to use, what template needed selecting. These are some of the threads I read up on to begin with:
Add additional_css.css to all your pages Code:
global $style; $vbcsspath = 'css.php?styleid=' . $vbulletin->userinfo['styleid'] . '&langid=' . LANGUAGEID . '&d=' . $style['dateline'] . '&sheet='; $find = '</head>'; $add_before = '<link rel="stylesheet" type="text/css" href="'.$vbcsspath.'additional_css.css,additional_css2.css" />'. PHP_EOL; $output = str_replace($find,$add_before.$find, $output); Code:
#pagetitle { background: none repeat scroll 0 0 yellow; clear: both; padding: 5px 0 0; } So now I had a simple addon installed which allowed me to add custom CSS to the template, which would show on all pages. I then looked at the product to see how it worked. Code:
$vbcsspath = 'css.php?styleid=' . $vbulletin->userinfo['styleid'] . '&langid=' . LANGUAGEID . '&d=' . $style['dateline'] . '&sheet='; Code:
$find = '</head>'; Code:
$add_before = '<link rel="stylesheet" type="text/css" href="'.$vbcsspath.'additional_css.css,additional_css2.css" />'. PHP_EOL; Code:
$output = str_replace($find,$add_before.$find, $output); It finds the variable $find, then replaces it with the variable $add_before.$find. The "." (dot) inbetween $add_before & $find is important as this ensures that the varibale $find is NOT replaced, but rather added after our variable $add_before. Now that I knew how to achieve this, I then began to create my own plugin, using the same code that was in the product I installed. I created a new template and replaced additional_css.css with the new template name. I then added the page title CSS code into the new template, using the hook location global_complete to see if it worked. And it did! Custom Plugin & Template Because I knew how to make the page title background colour change using a simple plugin, I began to make other changes this way. My first future addon, blah, was my initial test making the plugin, the template and getting it to work. I created a new template called "vbm_postbit_avatar_effect.css" and put the following code inside: Code:
.postbitlegacy .userinfo .postuseravatar { opacity:0.5; transition: all 0.5s ease-in; -moz-transition: all 0.5s ease-in; -webkit-transition: all 0.5s ease-in; } .postbitlegacy .userinfo .postuseravatar:hover { opacity:1; } Product: vBulletin (as I wasn't adding the plugin to any custom products yet) Hook Location: global_complete (as this was the hook location of the additional_css.css plugin from the addon I used initially) Title: Render the CSS Execution Order: 5 (by default) Plugin PHP Code: Code:
global $style; $vbcsspath = 'css.php?styleid=' . $vbulletin->userinfo['styleid'] . '&langid=' . LANGUAGEID . '&d=' . $style['dateline'] . '&sheet='; $find = '</head>'; $add_before = '<link rel="stylesheet" type="text/css" href="'.$vbcsspath.'vbm_postbit_avatar_effect.css" />'. PHP_EOL; $output = str_replace($find,$add_before.$find, $output); Then I went to view a thread where a member had an avatar, moved my mouse over the avatar and I could see that it had now changed and the plugin had taken affect. Before After on Hover |
#2
|
||||
|
||||
Thanks for the article! (images not showing)
|
3 благодарности(ей) от: | ||
Black Snow, CAG CheechDogg, RichieBoy67 |
#3
|
||||
|
||||
sir plz check images and upload again
|
#4
|
||||
|
||||
Well, there's TMS that does what you're wanting to achieve with this mod, but at the moment I'm not sure if it works on newer vB versions (it works with 4.2.0, but not sure what's with higher versions).
This is one of the most useful mods for managing forum upgrades. Anyway, if you made mod that does that, it would be really great. :up: |
Благодарность от: | ||
Black Snow |
#5
|
|||
|
|||
Oh my God, this really help me to create a addon for my site. Many thanks Black Snow
|
Благодарность от: | ||
Black Snow |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|