View Full Version : Hack to Plugin
RobDog888
09-26-2007, 10:58 PM
<font color="darkgreen">I am almost finished with what is turning out to be a huge hack so I figure it would be great as a plugin. Problem: Since most of the code and db mods are already in place, how would I go about changing it to be a plugin? How are plugins usually created? After the mod is installed or add/modify the plugin as you develop it?
Thanks</font>
Kirk Y
09-27-2007, 01:46 AM
Move all your physical code to plugins using hook locations at or near where you need the code executed. Add any database changes you've made to the Product XML's Install Code through the Product Manager.
I used to hack the physical files and then transfer to plugins - but after a while you remember what hooks are called where, or you can simply search in the files to see where each hook is eval'd -- and simply code solely through the plugin system.
RobDog888
09-27-2007, 02:20 AM
<font color="darkgreen">Thanks but if I create a new product plugin and activate it, wont it execute any sql CREATE or ALTER TABLE queries?
I am not using any hooks so far as its all in new pages and templates with the exception of one modification to one standard template.
But while I develop my product I should be doing so via the xml plugin or ? What do you do for inbetween phases of developing the eventual plugin?
I asked earlier in another thread but never really got a detailed answer on hook usage. Could you point me to something other then a sentence or two in the vB docs?
Thanks
</font>
Dismounted
09-27-2007, 05:18 AM
You should be developing all the code via the product system. Any SQL queries you need run should be placed into the install code.
RobDog888
09-27-2007, 07:19 AM
<font color="darkgreen">Ok, will create the product now. By checking out the other products I see they all contain one or more Plugins. I can create those too but for a template edit how do I incorporate that into a plugin or the product?</font>
ragtek
09-27-2007, 07:29 AM
you can use tms (https://vborg.vbsupport.ru/showthread.php?t=152931&highlight=andreas+template) or replace the template at runtime, or write a description, what to change on installing
RobDog888
09-27-2007, 07:51 AM
<font color="darkgreen">So far I have a couple of new templates and one minor template edit. I think if it grows with more template edits then I will use TMS.
Thanks though as I think it will prove valuable :thumb:
So for a plugin, its mostly for injecting your code into the php file that you have edited and the product is just for the mysql code etc?
Oh and where would I place a new php file?
Edit: How do you get the plugin to create phrases and phrase groups?</font>
Kirk Y
09-27-2007, 09:44 AM
Think of the product as the house that contains all the plugins, phrases, templates, etc. When you add your Install/Uninstall code to the Product, it doesn't get executed - it's only run at Installation/Uninstallation.
You can place your new PHP file wherever - depending on what its purpose is; if it's to be accessed by users, then it should probably be right below your forum directory.
Make sure your testboard is in debug mode, so you can access the developer options when creating new phrases and templates. You'll see a dropdown box below the Phrase/Template title where you can select a Product that it will go along with.
RobDog888
09-27-2007, 02:31 PM
<font color="darkgreen">Ok, will do. As for the php file its already in place and working fine, just looking for placement in the plugin or product for installation of the php file?</font>
Kirk Y
09-27-2007, 03:31 PM
Not sure what you mean in regard to installing the PHP file. If it just needs to be uploaded, simply tell the user as much - there's nothing additional you need to do in the Product.
RobDog888
09-27-2007, 04:33 PM
<font color="darkgreen">Ive seen some product xml files on this site that have php file nodes or what seems to be installing them I thought.</font>
Kirk Y
09-27-2007, 10:28 PM
No... unless it contains functions you'd like to use during the installation process, there's no need.
RobDog888
09-28-2007, 01:13 AM
<font color="darkgreen">Ok then how do you do an installation from just an xml file?
I have php files, templates, plugins, and phrases. I think they all should be in the xml file except the php files?</font>
Kirk Y
09-28-2007, 01:19 AM
Once you've set all your templates, plugins, and phrases to your Product (through the dropdown menu I talked about earlier), just go to Product Manager and Export your XML file through the Dropdown menu next to your Product.
This is what the end-user imports into their board; installing all the templates, plugins, and phrases, and executing any installation queries.
RobDog888
09-28-2007, 04:41 AM
Ah ok (light clicks on) :D
Thanks
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.