Hi all,
(Reposted as previous was posted in wrong category)
I have generated a component for testing with Cook and am now migrating it to work on Joomla 3.0. Back-end went fairly smoothly, but seem to have an issue with SEF and the front-end when I am accessing the component via a menu (or any SEF link really).
So for example when I do this:
www.mydomain.com/index.php?option=my_component&view=myview
It works fine.
But this:
www.mydomain.com/componentname/myview
results in a infinite redirect loop.
I have been checking the router.php generated by Cook and it seems to endlessly call the buildRoute.
This is the code of the router.php:
/**
* Build the route for the com_wpf component
*
* @param array An array of URL arguments
*
* @return array The URL arguments to use to assemble the subsequent URL.
*/
function WpfBuildRoute(&$query) {
logThis("Building Route\n");
logThis("Query:\n");
foreach ($query as $field=>$value) {
logThis($field.'=>'.$value."\n");
}
logThis("\n");
$segments = array();
if (isset($query['view'])) {
logThis("We have a view {$query['view']}\n");
$view = $query['view'];
$segments[] = $view;
unset($query['view']);
}
if (isset($query['layout'])) {
logThis("We have a layout {$query['layout']}\n");
$segments[] = $query['layout'];
unset($query['layout']);
}
if (isset($query['id'])) {
if (in_array($view, array('country', 'editcountry', 'projectstatus', 'editprojectstatus', 'projecttype', 'editprojecttype', 'service', 'editservice', 'sector', 'editsector', 'client', 'editclient', 'clientsector', 'editclientsector', 'project', 'editproject', 'screenshot', 'editscreenshot', 'serviceapplied', 'editserviceapplied'))) {
$segments[] = (is_array($query['id']) ? implode(',', $query['id']) : $query['id']);
unset($query['id']);
}
};
logThis("Segments:\n");
foreach ($segments as $field=>$value) {
logThis($field.'=>'.$value."\n");
}
logThis("\n\n");
return $segments;
}
/**
* Parse the segments of a URL.
*
* @param array The segments of the URL to parse.
*
* @return array The URL attributes to be used by the application.
*/
function WpfParseRoute($segments) {
logThis("Parsing route\n");
logThis("Segments:\n");
foreach ($segments as $field=>$value) {
logThis($field.'=>'.$value."\n");
}
logThis("\n\n");
$vars = array();
$vars['view'] = $segments[0];
$nextPos = 1;
if (isset($segments[$nextPos])) {
$vars['layout'] = $segments[$nextPos];
$nextPos++;
}
//Item layout : get the cid value
if (in_array($vars['view'], array('country', 'editcountry', 'projectstatus', 'editprojectstatus', 'projecttype', 'editprojecttype', 'service', 'editservice', 'sector', 'editsector', 'client', 'editclient', 'clientsector', 'editclientsector', 'project', 'editproject', 'screenshot', 'editscreenshot', 'serviceapplied', 'editserviceapplied')) && isset($segments[$nextPos])) {
$slug = $segments[$nextPos];
$id = explode(':', $slug);
$vars['id'] = (int) $id[0];
$nextPos++;
}
logThis("Vars:\n");
foreach ($vars as $field=>$value) {
logThis($field.'=>'.$value."\n");
}
logThis("\n\n");
return $vars;
}
Does anybody else had this problem and/or know how to fix it?
Many thanks,
Misha