Register Members List Search Today's Posts Mark Forums Read

Reply
 
Article Options
Whos Online Titles
Adrian Schneider
Join Date: Jul 2004
Posts: 2,528

by Adrian Schneider Adrian Schneider is offline 22 Apr 2006

Prerequisite: [HowTo] Add Custom Pages to WOL

If you have spent any time adding your custom scripts to show up as valid locations, you have probably wondered how to get the title of the blog entry, download, help ticket, store item, etc...

For my example, I'll base it on my project I was working on which was a blog system. Assuming the user views viewblog.php?userid=1, we can access the userid value of 1 using the 'values' element of $userinfo. The values element contains all the $_GET info of the user that was viewing.
Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

This adds to the list of userids that need the title queried for.


The next step is to retrieve those titles that we need, and to do this we use the "online_ids_titles" hook.
Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

It is crucial that you give $blogUserids and $wol_blogUserids global scope here, because we are currently inside a function! The above code only functions if $blogUserids is true (contains value) so it will not function if no users are currently viewing any blogs. Each row from the database will be stored in an array associating the ID with the Title so we can easily access it later.

The final step is to show the data... in my plugin in the "online_location_unknown" hook, I have a switch for $userinfo['activity'] (which is defined above), so I can assign the text and newly retrieved title of the blog.
Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Again, we need to give global scope (this time to $wol_blogUserids), so that we can access the title of the blog. I assign $blogUserid and $blogTitle the values we want to use in the link, just because it makes writing the string easier and takes up less horizontal space. $userinfo['action'] is the main action that displays, and $userinfo['where'] is the extra optional bit of information that is displayed to the side or below.

To make any use of this, you will have to heavily modify it to work with your table structure and vb extension, but this should give you enough of an idea how to do it to be at least somewhat successfull.
Views: 3622
Reply With Quote
Comments
  #2  
Old 26 Nov 2008, 04:15
veenuisthebest's Avatar
veenuisthebest veenuisthebest is offline
 
Join Date: Mar 2008
Real name: Vinayak
Worked great! Thank you so much for this. I don't know how many times and on how many forums I have asked this. Thanks again

alright, just one question plz. How do I get a third variable available for userinfo[where]. Say we have id and title, I also want to extract url column value from database to use in the location path.

I am able to do it by querying url ofcourse and creating another global variable $wol_urls.

Just wanted to know if its the best way. Thanks

Last edited by veenuisthebest; 26 Nov 2008 at 06:05.
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Article Options

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


New To Site? Need Help?

All times are GMT. The time now is 10:27.

Layout Options | Width: Wide Color: