View Full Version : Converting a mod from vb3 to vb4
markuswarren
04-03-2012, 12:49 PM
<i>Moderators, if this should be in the prog discussions forum, please move</i>
I have a mod I created for vb3 and I am thinking it is probably time to move over to vb4. I know there are substantial differences between the versions, so I'm looking for help and advice.
The main areas I'm concerned about are:
1. Preferences / options changes. I have a couple of prefs that would appear under the General settings prefs (a global on / off option, plus an option for a globally visible item in the forum header), and I also have per forum settings (display a specific item to the right of the forum / sub-forum name in the listing - plus in forumhead)
2. vb code in the templates to check status of an option (show in this forum type of thing)
3. hooks. I use a couple of hooks to ensure the code appears in the right place.
I know, I'm being somewhat vague to say the least. Would it be acceptable to post the contents of my mods .xml file in the thread for someone to have a look over?
Thanks in advance for any suggestions / advice / comments
You may find there isn't as much difference as you imagined. I think the biggest change is template syntax, but if you don't have any templates your mod might work without any changes (there are a number of mods that work in both vb3 and vb4 with no changes).
You can post your product here if you wrote it (Don't post someone else's code here without their permission). Use CODE tags around it. If it's large you might want to attach the file instead of posting the contents.
markuswarren
04-03-2012, 10:00 PM
Thanks for the reply.
It is my own mod, and I've never published it anywhere previously, it's only in use on one board (one I manage).
Product is attached to this message.
I do have a few template edits, but I make them manually, rather than auto insertion, essentially they perform a conditional check on wether a vb option has been enabled or not. Here is the info file I created for myself for the "showthread" template edit (I have them for; showthread, forumhome_foumbit_level2_post, forumhome_foumbit_level1_post, and forumdisplay)
Positioning of the SHOWTHREAD template code:
Edit the SHOWTHREAD template and look for the following:
<if condition="$show['inlinemod']">
$spacer_close
<form action="inlinemod.php?threadid=$threadinfo[threadid]&p=$postid" method="post" id="inlinemodform">
$spacer_open
</if>
<a name="poststop" id="poststop"></a>
Place the template code below this block of code
Template Code:
<!-- START - mrwrb -->
<if condition="$foruminfo[mrwrb_showthread_banners_enabled] == 1 AND $vboptions[mrwrb_global_enable_banners] == 1">
<style type="text/css">
#mynicebannerouter {height: 105px; overflow: hidden; position: relative; width: 100%;}
#mynicebannerouter[id] {display: table; position: static;}
#mynicebannermiddle {position: absolute; top: 50%; width: 100%; text-align: center;} /* for explorer only*/
#mynicebannermiddle[id] {display: table-cell; vertical-align: middle; position: static;}
#mynicebanner {position: relative; top: -50%; text-align: left;} /* for explorer only */
#mynicebanner {width: 500px; margin-left: auto; margin-right: auto;} /* for all browsers*/
#mynicebanner[id] {position: static;}
</style>
<div id="mynicebannerouter">
<div id="mynicebannermiddle">
<div id="mynicebanner">
</div>
</div>
</div>
$mrwrb_forum_large
<SCRIPT LANGUAGE="JavaScript">
rotateImage('mynicebanner')
</SCRIPT>
</if>
<!-- END - mrwrb -->
Once again, thanks for any help or comments :)
OK, well, I looked it over and didn't immediately see anything that wouldn't work with vb4. I changed the maxversion of the xml file then imported it to my test site and there weren't any errors and your options came up in the forum manager. That's as far as I went. You're obviously going to have to redo the templates and instructions for vb4 but other than that I don't see why it wouldn't work.
markuswarren
04-05-2012, 10:31 AM
Thank you very much indeed for your help. I'll give it an import and see where I'm at.
markuswarren
04-06-2012, 10:50 AM
It did indeed import :)
I do have one problem so far, and the is with the plugin / template edits.
From the posted example I am calling a variable: $mrwrb_forum_large
This does not seem to work, probably as I need to change it to {vb:raw mrwrb_forum_large} but that too seemingly does not work.
What else do I need to do to get this variable read / included into the template (it's coming from a plugin, but I do have one that reads from another template too)
The variable needs to be "registered" to the template. Here's an article on that: https://vborg.vbsupport.ru/showthread.php?t=228078
But essentially, since you want to put it in the SHOWTHREAD template, which of course is an existing template, you'd use vB_Template::preRegister(), like this:
vB_Template::preRegister('SHOWTHREAD', array('mrwrb_forum_large' => $mrwrb_forum_large
));
This needs to go in plugin code at some point after the value of $mrwrb_forum_large has been set.
markuswarren
04-06-2012, 01:46 PM
Thank you.
One assumes that as I have similar things for forum display, forumhome_forumbit_level1_post, and forumhome_forumbit_level2_post that I can simply change the SHOWTHREAD in the template register line to those names?
Sorry to take up your precious time, I really do appreciate it.
Thank you.
One assumes that as I have similar things for forum display, forumhome_forumbit_level1_post, and forumhome_forumbit_level2_post that I can simply change the SHOWTHREAD in the template register line to those names?
Yes. And if you have more than one variable to register to the same template, you can add to the array and do it in one call (one per template, that is).
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.