In vb4 we had THIS_SCRIPT - it was working great. Not it is gone. The replacement is pageid, BUT:
1. It is not easy to get (if it is please give me the method to get it)
2. It is not alvays available - often I get 0, because I'm asking too fast for it, anf vB5 didn't initiate some thing yet (I got route with empty data)
3. pageid is not human readable so it is pain in the ass.
So - how can it be easily taken (please give code) and where it the EARLIEST place I can use it in plugins. I can tell that it is SOMETIMES working fine in state.php. And vB gives empty route in route.php, node.php (this is not always used because of cache), options.php... You made things so complicated for no reason. Or at least I do not know the right way to take pageid always appropriatelly and where I want to...
The code I'm using is taken from vB5 code (I add my own global to make thinks easier, but I have issues I described above). It is added in plugin state.php, outside any class, so it is executed when plugin is loaded:
Often I get 0, and often I need to ask for VBET_PAGEID before the plugin is loaded, but earlier plugins give empty router (print_log is my own function, so I can see what I got).
I made also function to load pageid ad hoc, but of course mostly I got there empty router and pageid is 0, even when it really isn't...
Can you make any easy way to determine the page like it was with THIS_SCRIPT? Can it be human readable? Can you give me solution for working with pageid in actual form in vB5?
1. It is not easy to get (if it is please give me the method to get it)
2. It is not alvays available - often I get 0, because I'm asking too fast for it, anf vB5 didn't initiate some thing yet (I got route with empty data)
3. pageid is not human readable so it is pain in the ass.
So - how can it be easily taken (please give code) and where it the EARLIEST place I can use it in plugins. I can tell that it is SOMETIMES working fine in state.php. And vB gives empty route in route.php, node.php (this is not always used because of cache), options.php... You made things so complicated for no reason. Or at least I do not know the right way to take pageid always appropriatelly and where I want to...
The code I'm using is taken from vB5 code (I add my own global to make thinks easier, but I have issues I described above). It is added in plugin state.php, outside any class, so it is executed when plugin is loaded:
Code:
if (!defined('VBET_PAGEID')) { $router = vB5_ApplicationAbstract::instance()->getRouter(); if ($router) { print_log("ROUTER: ". print_r($router, true)); $arguments = $router->getArguments(); $pageid = (int) (isset($arguments['pageid']) ? $arguments['pageid'] : (isset($arguments['contentid']) ? $arguments['contentid'] : 0)); DEFINE('VBET_PAGEID', $pageid); } }
I made also function to load pageid ad hoc, but of course mostly I got there empty router and pageid is 0, even when it really isn't...
Can you make any easy way to determine the page like it was with THIS_SCRIPT? Can it be human readable? Can you give me solution for working with pageid in actual form in vB5?
Comment