Hello,
I'm quite new to Zend Framework (and especially to this forum) so probably you will see me around more often
Currently i am trying to use Zend Framework on top of another framework (Joomla CMS/Platform). I understand that this might not be the best combination, but ok, choice was made
It's all working quite well but I ran in to some routing problems and i'm hoping you experts can help me out.
I have 2 modules ('admin' and 'site') and i am trying to route the requests to the right pages. Depending on the url i need to check if i need to load the admin or the site module.
Currently the url "/administrator/index.php?option=com_webshop&module=admin&controller=attribute&action=edit" should load the admin module (which should be easy to regonize because of the '/administrator' in the url.
But what is the best way to do it? At the moment i use the code below to route to the admin module.
// I know the following code makes probably not much sense, but i have no idea how to do it !
$front = Zend_Controller_Front::getInstance();
$front->setBaseUrl('/');
$router = $front->getRouter();
$action = JRequest::getVar('action');
$controller = JRequest::getVar('controller');
$format = JRequest::getVar('format', 'html');
$administrator = new Zend_Controller_Router_Route_Regex(
'administrator/index.php',
array(
'module'=>'admin',
'controller'=> $controller,
'action'=> $action,
'format'=> $format,
),
array(
1=>'module',
2=>'controller',
3=>'action',
4=>'format'
),
'administrator/index.php?option=component_name&module=%s&controller=%s&action=%s&format=%s'
);
$router->addRoute('administrator', $administrator);
$front->setRouter($router);
The code works, but not like i want it to. It loads the admin module based on the '/administrator' part, but now when I use the url helper (see example below) in my viewscript all the extra params get stripped off.
$this->url(array('controller'=>'attribute','action'=>'add.value.form', 'format'=>'json', 'extraParam' => 'test', 'extraParam2' => 'test2'));
// Generates: index.php?option=com_webshop&module=admin&controller=attribute&action=edit&format=json
// with the extraParam & extraParam2
If I dont use this router it doesn't get into the admin module. I have no idea where to go from here so any help is welcome!
Hope my explanation was a bit clear.
Thanks in advance,
Marco