View Single Post
  #2  
Old 28 May 2015, 06:23
MarkFL's Avatar
MarkFL MarkFL is offline
 
Join Date: Feb 2014
Real name: Mark
5.) Write The Plugins

The first plugin will cache the custom templates if appropriate, that is, if the product is enabled, the right script is running and the associated setting is enabled.

So, follow:

AdminCP ► Plugins & Products ► Add New Plugin

Select the product we are developing, and then enter:

Hook Location: cache_templates

Title: Cache Templates

Execution Order: 5

Plugin PHP Code:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

The next plugin will create the template group for our product so that when the user views all the templates when editing templates, our custom templates will be grouped together for efficient organization.

So, add another new plugin, and choose the product we are developing, and then enter:

Hook Location: template_groups

Title: Create Product Template Group

Execution Order: 5

Plugin PHP Code:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

This instructs vBulletin to put any templates whose title begins with the string "markfl_thanks_" into a group named "MarkFL: Display DBTech Thanks Data."

The next plugin will instruct vBulletin to replace its default template with our custom version (if our product is enabled, thanks data on profiles is enabled, and the template to be replaced is running). So, add a new plugin and choose the product we are developing, and then enter:

Hook Location: template_render_output

Title: memberinfo_block_statistics Template Replacement

Execution Order: 5

Plugin PHP Code:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

The next plugin will render the thanks data in user postbits, if the appropriate settings are correct, and only for posts in threads or private messages, and if the user has not disabled the postbit stats in their settings for DBTech's product.

Hook Location: postbit_display_complete

Title: Render Thanks Data In Postbits

Execution Order: 1 (I wanted to ensure that the thanks data goes right below the number of posts in the postbit)

Plugin PHP Code:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

And the last plugin will render the thanks data on user profiles if the settings are appropriate:

Hook Location: member_build_blocks_start

Title: Render Thanks Data On Profile

Execution Order: 5

Plugin PHP Code:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Okay, we now have all the coding done, and it is time to export the product, which will create the XML file we can distribute to others.

6.) Export The Product

Follow:

AdminCP ► Plugins & Products ► Manage Products

Scroll down to the product we have developed, and on the right, from the drop-down menu for our product, click "Export" and save the XML file in an appropriate location on your hard drive. I like to put each product's files in its own folder.

You should write a text file instructing those who download your product how to install it and state the purpose of the product and give its development history.

7.) Zip Up the Files

Use an application of your choice to compress all of the files associated with your product into a ZIP file. Now you are ready to share your product with others. If you are uploading here, you should be sure to include screenshots of your product's setting page in the AdminCP and your product in action.

The product developed in this article is very modest, but I wanted to keep it simple for the purposes of a tutorial on the general method for using vBulletin's intrinsic tools for developing and sharing products. I encourage those of you with years of experience, rather than the weeks of experience I have under my belt to offer further insights and/or corrections to what I have written.
Reply With Quote