Log in

View Full Version : Error: function query_first_slave()


ptmuldoon
03-22-2009, 04:57 PM
I'm trying to get the Cybtopstats to show on a non-vb page in an MkPortal CMS. I understand its difficult (perhaps impossible) to get the stats to show on a portal. I can get the stats to show on a normal, non-vb page, just not in my portal.

So in learning/playing, I wanted to see about returning the stats information from a function, but am getting an error of:

Fatal error: Call to a member function query_first_slave() on a non-object in C:\wamp\www\mkportal\forum\includes\functions.php on line 1319

And this is the entire php page/function at the moment. I really have no idea what would be causing the error. I'm not connecting or changing to different DB's or anything as I saw could be a cause for this error.


function teststats()
{
$cwd = getcwd();
chdir("../../forum/"); //Path from Mkportal blocks
//chdir("./forum/"); //Path from mkportal index
require_once('global.php');
chdir($cwd);

$stats = $cybtopstats;
return $stats;
}

$test = teststats();
echo $test;

Lynne
03-22-2009, 04:59 PM
Probably that you are calling global.php again. You should only call it once on a page.

ptmuldoon
03-22-2009, 06:09 PM
Probably that you are calling global.php again. You should only call it once on a page.

Thanks for the help. But can you explain how I would be calling the global.php file more than once? This is all in a non-vbulletin page, and the above function is the only code at the moment.

Wouldn't calling the function be getting the global.php file once?

Lynne
03-22-2009, 06:23 PM
That is all that is in the php page? You need much more than that. See this article - [How-To] vBulletin API Basics: Creating Custom Pages & Misc. (https://vborg.vbsupport.ru/showthread.php?t=98009)

If you need more help, you should post the whole php page and template here.

ptmuldoon
03-22-2009, 09:22 PM
Perhaps I'm confusing myself or not explaining correctly. Currently, I am trying to include the Cyb - Advanced Forum Statistics (https://vborg.vbsupport.ru/showthread.php?t=201274&highlight=Statistics) into the MKPortal cms. It appears that adding these stats to any portal can be rather difficult.

I learned that I can create a non-vb page and show the stats with the below code (add adding the file name to the cybtopstats options), without adding all of the information from the link you provided. I don't think its needed to include all the additional vb phrases, etc or is it?


define('THIS_SCRIPT', 'cybtopstats');
$cwd = getcwd();
chdir("../../forum/"); //Path to forums
require_once('global.php');
chdir($cwd);
echo $cybtopstats;


The problem now is just finding a way to get that same information to show on a portals home page. That above code works by itself, but does not seem to work when added to a portal/cms. Again, it seems an issue with trying to get the stats to show on various cms/portals. I'm unsure why that would be the case though, but it seems to be a difficult task.

So I'm looking at various other ways to try and access the $cybtopstats. One thought was to try and do it in a function, and call the function in the portal. Perhaps thats not the best approach. I am open to any suggestion to echo the data.

Lynne
03-22-2009, 10:32 PM
If you want to include $cybtopstats in another page, you need to actually define it somewhere. Simply echoing it will do nothing because nowhere in that code do you actually define it. (Unless it is somehow defined in some plugin that gets called in global.php?) And, if you expect it to be included in a portal page, does that portal page already 'include' the global.php page or any other vb page?

ragtek
03-22-2009, 10:35 PM
I think the best way is to look what the cybtopstats plugin is doing and to copy the code the code instead of including the whole vb "framework"

ptmuldoon
03-23-2009, 01:40 PM
I think the best way is to look what the cybtopstats plugin is doing and to copy the code the code instead of including the whole vb "framework"

I would probably have to agree, and think looking to copy the plugin code is the best approach. Somehow the global.php file is defining the $cybtopstats template variable, since including the global and echoing the variable does work, without defining the variable first.

I had copied the plugin code out, and its pretty complex stuff. I'll have to think more on it going forward, and see what I can learn from the plugin code.