MyBB Community Forums

Full Version: Adding tracking to a page
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Heloo all,

I was wondering how it is possible to add tracking to any page i made.
so when u go to who's online, you can find that person browsing that page which is not originaly came with mybb.

For example i made a page rules.htm, so how to make a track for it.


Thanks in advance
I made a thread about this before as well and nobody could figure it out.

Here's my original thread

http://community.mybboard.net/showthread.php?tid=4664
Ok. Since noone else is replying, I had a quick look. I've not looked at it much but this is my take on it.

Look for the line "switch($filename)". This switch handles what file they are on. So if you are creating a new file for users to go to, you will need to add another case to this switch. Note that it ignores the file extension. It only uses the actual name in the switch statement.
Then depending on your files' complexity, you can have another switch statement as to what action they are doing on that page. A sort of filter.
In your case statement (don't forget the break command at the end!) you will need to put something similar to "$user['activity'] = "calendar_event";". Replace "calendar_event" with your own unique identifier (example "my_handle").

This happens for each user . The information is added to a user array. And the tables are queried for extra information, things like topic titles, forum names etc. This information is put into an array, but the order that the things you need from the SQL (topic id, topic title) determine what to do in a few steps time.

You then need to look for "switch($user['activity'])". This handles the message people see when they visit your page. You need to add the unique identifier you made in the last step. So in the above example you would add a "case 'my_handle':". In this handle you need to define "$locationname" with the message you want people to see when they view online.php

(You only need to read this if querying information from the database)
The strings take the form of sprintf statements. This is where the order of the selected columns comes into play. When you select stuff from tables using "SELECT topic_id, topic_title FROM.....", the topic_id is stored in array index 0 and topic_title in index 1. Once you know the order of the items you selected you can use these values in your sprintf strings. Note that if you want to get the value in array index 0, you need to use "{1}" in your sprintf string.
For example your string could be "You are viewing my page and you user id is {1}", assuming you queried the database with something like "SELECT uid FROM users WHERE....".


I've not explained it very well I know but maybe it'll help you. I've only looked at the code for a few mins so I could be totally wrong Smile