JPagination and SEF

23 views
Skip to first unread message

Nick Weavers

unread,
May 17, 2012, 6:58:19 PM5/17/12
to joomla-de...@googlegroups.com
In my component am using a router to handle my sef url's and am having trouble with a paginated list generated by the component. JPagination (JRoute) is getting the SEF path segments out of order for the page links.

For the form tag containing the pagination I have the following: 
<form name="search_form" id="search_form" action='index.php?option=com_chimneypots&task=admin.showAgentsSellersProperties&Itemid=526' method="POST" >

I am also using a custom router that looks like this:

function chimneypotsBuildRoute(&$query) {
$segments = array();
// we use sub controllers extensively in com_chimneypots so no need to check for controller,
//it will be part of the task string. Put the task string first
$i = 2;
foreach ($query as $param => $value ) {
if ($param == 'option' ) {
list($tmp, $component_name) = explode('_',$query['option']);
$segments[0] = $component_name;
unset ($query['option']);
} elseif ($param == 'task' ) {
$segments[1] = $query['task'];
unset ($query['task']);
} else {
$segments[$i] = "{$param},{$value}";
$i++;
unset ($query[$param]);
}

}
  return $segments;
}

function chimneypotsParseRoute($segments) {
    $query = array();
    // The first segment should be the task, the rest we'll decode
    $query['task'] = $segments[0];
    unset($segments[0]);
    $num_segments = count($segments);
    for ($i=1; $i <= $num_segments; $i++) {
list($parm, $value) = explode(',', $segments[$i]);
$query[$parm] = $value;
    }
    for ($i=1; $i <= $num_segments; $i++) {
    unset($segments[$i]);
    }
    return $query;
}

The problem I am having is that when pagination->getListFooter() is run at the bottom of my form, it doesn't appear to be calling my router which would get the segments in the correct order. Instead it generates the path:
"/index.php/component/chimneypots/Itemid,526/adminAgentSeller.showAgentSellersProperties".
I can see the incorrect path being generated at the point show in the call stack

Just after executing line 649 I can see the "out or order" sef link in $data->all->link:

In the generated link "/index.php/component/chimneypots/Itemid,526/adminAgentSeller.showAgentSellersProperties", the segment "Itemid,526" should come after "adminAgentSeller.showAgentSellersProperties".

Should JRoute be calling chimneypotsBuildRoute to build the URL or am I doing something wrong?

TIA,

Nick

 



                                                                                                                                




Nick Weavers

unread,
May 18, 2012, 8:00:08 AM5/18/12
to joomla-de...@googlegroups.com
Sorry, my mistake, it appears my router was getting called but I needed a ksort on the segment array in chimneypotsBuildRoute before returning it. (Don't know why I just assumed it would be sorted on its indices.. ) 

Nick  

 
Reply all
Reply to author
Forward
0 new messages