MyBB-Plugins Forums

Full Version: Adding the total at the home stat
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello, after making this little change at this great plugin :

I have an other idea but I don t know how to start it.

I would like to add, at the home page, the total amount of point generated by users.
I ve easily implemented it at the newpoints.php page using this function on the plugin newpoints.php

PHP Code:
function get_total()
$total 0;
$query $db->write_query("
        SELECT newpoints FROM "
.TABLE_PREFIX."users WHERE newpoints>0
$points $db->fetch_array($query))
$total $total $points['newpoints'];

and then adding this to the menu :

PHP Code:
$menu[0] = '<a href="#">Total: 'newpoints_format_points(get_total()) . '</a>'

But now, how can i call this variable, or the function from the portal template ?

thank you
You must add a hook to portal_start or portal_end (either should work depending on what you want to do) and then add that variable to the global variables list.

Also, you should use MySQL to SUM all that, don't leave it to PHP.
Thank you for your explanation, the problem is fixed Smile