MyBB Community Forums

Full Version: [SAMPLE] Making new pages work with Who's Online
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Here is an example of a plugin that adds titles and links to non-standard pages in MyBB's Who's Online pages (online.php)

It also uses MyBB's SEO functionality if it is enabled.

For language support you need to use my Custom Language File plugin and add your language there or create language files specific to the new pages and edit/enable the one line that loads the file.

This is a working example based on content from my own site, so it will not work with any other existing setup without edit, but it will give you a good example of how to make the Who's Online Page show something other than "Unknown Page"

An example of the language file variable that get used are

$l['viewing_tech_list'] = "Viewing <a href=\"../{1}\">Technical Article List</a>";
$l['viewing_garage'] = "Viewing <a href=\"../{1}\">{2}</a> Technical Article";

You can see a working example for my Technical Articles plugin as well as my Garage plugin

Who's Online page
http://www.pavementsucks.com/board/online.php

Tech page
http://www.pavementsucks.com/tech.php

Garage
http://www.pavementsucks.com/garage.php
So this plugin will show a custom message for a defined URL, like the articles in your forum?

Where I have to define the language file? in the global.lang.php?
The above plugin will simply handle the text in the "Location" field of the Who's Online page (<your board>/online.php) for non-standard MyBB pages, in this case a page or set of pages called tech.php that may or may not have query strings that contain "article" and "page" parameters.

If your site integrates with the main MyBB code like mine does, the Who's Online page will show "Unknown Page" in as the location for a user that is not on one of MyBB's standard pages. An example would be if you are browsing my Tech section.

By integrated, non-standard page, I mean one that results in the MyBB session table containing the REQUEST_URI in its location field. If the MyBB session handler is not used on the page in question, then this sample plugin does you no good.

The sample plugin I posted shows how to make non-standard pages that are integrated with MyBB properly show in Who's Online. It is specific to a page or set of pages and is not generic since there is an infinite number of possible pages/query strings to support. To use it, you will need to consider the filename and query parameters

As for the language, you can use my Custom Language File plugin and update the custom.lang.php file or create a separate language file and uncomment the $lang->load line and update the language name.

The reason the language files need to be handled this is because MyBB loads the plugins before the standard language files.