How can i create a location for a custom page? When i say location i mean (Whos Online) it shows a location on the forum and what they are doing. I made a
custom page for dvz_shoutbox as a sub page. However it shows people as unkown location when on that page. I would like it to say something like "Chat"
thanks for hte link
Where do these actual functions get executed? And what does the hook contain? Something like?
$plugins->add_hooks(my_plugin_wol)
Is the add_hook like a hash map linking the execution at the point of run_hook and the definition of the hash map at add_hook linking your string (in my case "blah") to the functions?
For example i editing /inc/plugins/dvz_shoutbox.php and added the following
$plugins->add_hook('dvz_shoutbox_start', ['dvz_shoutbox', 'load_window']); // load Shoutbox window to {$dvz_shoutbox} variable
$plugins->add_hook('blah', ['dvz_shoutbox','dvz_shoutbox_wol']);
$plugins->add_hook('blah', ['dvz_shoutbox','dvz_shoutbox_friendly_loc']);
//metulburr
//added dvz_shoutbox_wol and dvz_shoutbox_friendly_loc in attempt to add online location to shoutbox page
function dvz_shoutbox_wol($user_activity)
{
global $parameters;
if(strpos($user_activity['location'], "dvz_shoutbox.php"))
{
$user_activity['activity'] = "Using Shoutbox";
// If I had any parameters I would do them like this:
$user_activity['parameter_name'] = $parameters['parameter_name'];
}
return $user_activity;
}
function dvz_shoutbox_friendly_loc($array)
{
global $user_activity;
/* Globalize $db if you want to query the database for needed parameters.
* Also whichever variable you cache data in needs to be globalized.
* Globalize $cache if you are reading from a cache.
*/
if($array['user_activity']['activity'] == "Using Shoutbox") /* Replace my_file with whatever you called the activity in the previous function. */
{
$array['location_name'] = "<a href=https://python-forum.io/shoutbox.php>Shoutbox</a>";
}
return $array;
}
and in my custom page in my mybb root i have shoutbox.php
<?php
define('IN_MYBB', '1');
define('THIS_SCRIPT', 'shoutnox.php');
require "./global.php";
$plugins->run_hooks("dvz_shoutbox_start");
$plugins->run_hooks("blah");
add_breadcrumb("Shoutbox", "shoutbox.php");
eval("\$page = \"".$templates->get("shoutbox")."\";");
output_page($page);
?>
This doesnt show an error, or warning, etc. However it is not doing anything. I am not sure if it is a hook problem or the functions are not correct?
I found out how to do it by hard coding it
https://community.mybb.com/thread-36884.html
Works and seems much more simpler to add cases for you custom pages than learning the plugin process.
I wouldn't recommend looking at the DVZ ones as examples because they are written a bit odd. Learning the plugin process is better than doing core file edits because each time you update the forum, you'll need to apply the edits again.