AbanteCart Community
AbanteCart Development => Development Help Needed => Topic started by: dhigz on December 16, 2015, 01:25:20 AM
-
Looking for developer help. I am working on a new extension and ran into a problem with the dispatch command.
In my extensions core file, I have the function: onControllerCommonSeoUrl_InitData(). I have a need for one page to execute a custom url different the the standard url output format generated by seo_url.php. This is the code I have:
public function onControllerCommonSeoUrl_InitData(){
if (isset($this->baseObject->request->get['_route_'])) {
$parts = explode('/', $this->baseObject->request->get['_route_']);
if($parts[0] == 'my_page_name') {
$this->request->get['m'] = $parts[1];
$this->request->get['y'] = $parts[2];
$rt = 'pages/XXXX/archive';
//name removed - don't want to say what the extension is yet
unset($this->baseObject->request->get['_route_']);
//this prevents the script in the base file (seo_url.php) from processing any other data
// The next two lines come from the end of seo_url.php
//This line works
$this->baseObject->router->resetController($rt);
// This is where the problem is...
return $this->dispatch($rt,$this->request->get);
}else{
foreach ($parts as $part) {
//continues ........
return $this->dispatch($rt,$this->request->get);
Dispatch does run but returns the correct layout for my page with blocks from the intended page and my index page.
I tried inserting baseObject as you should in an extension core file:
return $this->baseObject->dispatch($rt,$this->request->get);
This returns a blank page with the logged error: error: AbanteCart core v.1.2.2 Call to protected method AController::dispatch() from context 'ExtensionXXXXX'....
The page will load if I use the standard format non-seo url. It will also load if I use a RewriteRule in my .htaccess file (trying to avoid this). The values for dispatch route are correct ($rt = 'pages/XXXX/archive') and the values in the array are valid and correct. Values are correct in the block_layout table.
Any suggestions on what I need to do to get dispatch to properly run?
-
Hi, I think you can copy the dispatch function from the core code into your hook file, make it as a private function and then call the dispatch with $this->dispatch(xxxx). Hope it helps.
-
Thanks for the input. It didn't work but it did lead me to discovering my problem was much deeper.
Thanks.