Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 07-05-2006, 12:07 PM
Guest210212002
Guest
 
Posts: n/a
Default Writing my first plug-in/product, several newbie questions.

Disclaimer: I've been reading the API and will continue to do so, just trying to get a feel for this and hopefully some folks will be patient enough to do a little hand-holding.

I'm trying to write my first plugin, something extremely basic, just to get the feel for how it works. I'm decent with template edits and variables, but I've never attempted writing a plugin before, and would really like to.

That said, I'm looking to write a simple plugin to drop a variable into a template.

In FORUMHOME, here's the default Who's Online:

Code:
<a href="online.php$session[sessionurl_q]" rel="nofollow">$vbphrase[currently_active_users]</a>: $totalonline (<phrase 1="$numberregistered" 2="$numberguest">$vbphrase[x_members_and_y_guests]</phrase>)
All I want to do is add the following code after the end parenthesis:

Code:
Invisible: $numberinvisible
So that the end result is:

Code:
<a href="online.php$session[sessionurl_q]" rel="nofollow">$vbphrase[currently_active_users]</a>: $totalonline (<phrase 1="$numberregistered" 2="$numberguest">$vbphrase[x_members_and_y_guests]</phrase>) 
Invisible: $numberinvisible
I'm looking at This post on writing plug-ins and the first thing I need is the hook location. So I opened up forum/index.php, and I *think* that the proper hook location is (from around line 407):

Code:
($hook = vBulletinHook::fetch_hook('forumhome_loggedinuser')) ? eval($hook) : false;
Judging by that, the hook loction is forumhome_loggedinuser, correct?

So in using the basic code from the howto post, I come up with something like:

Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<plugins>
	<plugin active="1">
		<title>Chris's Newbie Plugin</title>
		<hookname>forumhome_loggedinuser</hookname>
		<phpcode>
<![CDATA[ ]]>
</phpcode>
	</plugin>
</plugins>
If I'm correct so far, I'm not sure:

A: Where the actual code goes.
B: How I tell vB where to actually put it, (Eg: "directly following $vbphrase[x_members_and_y_guests]</phrase>) ".

I'm guessing that the code that I want to inject goes inside the CDATA brackets, like this:

Code:
<![CDATA[Invisible: $numberinvisible]]>
But from there, I'm stumped, and that's assuming I'm even close to correct this far.

If anyone could shed some light on where I should go from here, I'd really appreciate the help. In the meantime I'll keep scouring the docs. :bunny:

Update #1

Here's what I have so far, but I don't think I'm going about it correctly:

Code:
<?xml version="1.0" encoding="ISO-8859-1"?>

<product productid="chris777_showinvisible" active="1">
	<title>Show Invisible Users</title>
	<description>Will add a count of invisible users in WGO.</description>
	<version>1.0.0</version>
	<codes>
	</codes>
	<templates>
	</templates>
	<plugins>
		<plugin active="1">
			<title>Show Invisible Users</title>
			<hookname>forumhome_loggedinuser</hookname>
			<phpcode><![CDATA[ 
if ($totalonline (<phrase 1="$numberregistered" 2="$numberguest">$vbphrase[x_members_and_y_guests]</phrase>)) 
{
Invisible: $numberinvisible;
}
]]>
</phpcode>
		</plugin>
	</plugins>
	<phrases>
	</phrases>
	<options>
	</options>
</product>
The if statement I'm guessing will look for that particular line in a template, and just stick my code after it.

[high]* Guest210212002 scratches his head and continues to dig.[/high]
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 02:32 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.14764 seconds
  • Memory Usage 2,207KB
  • Queries Executed 11 (?)
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
  • (7)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_wrapper
  • (1)showthread_list
  • (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_threadedmode.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_threaded
  • showthread_threaded_construct_link
  • 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
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete