cotonti.com : Global $db_pages in localhost is null? https://www.cotonti.com Last topic posts Cotonti en Mon, 13 Apr 2026 08:36:29 -0000 Trustmaster Right. The exception is when hooking to the page module itself. And of course you don't need to require the page module if your plugin has already done it in some other hook which is executed before current hook.

]]>
Tue, 05 Feb 2013 19:29:42 -0000
Eugene ok.

so, your guidline for pluginmaking - is to include functions of Page module each time I need to work with Pages and $db_pages...?

not to rely on that as on global variable?

]]>
Tue, 05 Feb 2013 17:58:11 -0000
Trustmaster The cause of the problem lays in the execution order. The availability of globals/functions depends on in which order files are required and the code is executed. Enabling/disabling cache affects this flow as well.

As plugin developers we prefer to require APIs we want explicitly every time we need it, because it is better than relying on some other plugin to do it for us, which simply might not be present.

]]>
Tue, 05 Feb 2013 14:34:56 -0000
Eugene Trust, it is what I may do easily, but I don't like it.

Let me clarify: if I do

global $db, $db_pages;

On hosting - I will get normal variable, but on localhost - null.

How I can fight it?

Добавлено 1 часа спустя:

I found a reason, i guess.

during development somtimes I turn off CACHE $cfg['cache'] = FALSE;

That makes those global variable null. I don't know if that's right, but I'm glad it's solved.

]]>
Mon, 04 Feb 2013 18:01:58 -0000
Trustmaster Your plugin should require page module to use its functions or tables, at the top of it do:

require_once cot_incfile('page', 'module');

 

]]>
Mon, 04 Feb 2013 17:40:21 -0000
Eugene Hello.

Guys, it is not first time i mentioned problems with my localhost apache:

some global variables are null !

When I upload site to hosting - it is working well. But while it is on localhost - I need to define variables...

example: plugin which works with hook users.details.tags

what is wrong?

]]>
Mon, 04 Feb 2013 17:24:37 -0000