Hello
I would like to have a pagenav (<xen:pagenav>) in a template which shows search results. I'm struggling to set it up so that it still shows the search results when i go to the next page.
In the template I have the following two possibilities:
The upper produces these links:
Important parts of the controller
I would like to have a pagenav (<xen:pagenav>) in a template which shows search results. I'm struggling to set it up so that it still shows the search results when i go to the next page.
In the template I have the following two possibilities:
HTML:
<xen:pagenav link="teams" linkdata="{$search}" page="{$page}" perpage="{$perpage}" total="{$totalTeams}" />
<xen:pagenav link="teams" page="{$page}" perpage="{$perpage}" total="{$totalTeams}" />
- http://127.0.0.2/index.php?teams/&search=insertedSearchString
- http://127.0.0.2/index.php?teams/&search=insertedSearchString
- http://127.0.0.2/index.php?teams/&search=insertedSearchString
- ...
- http://127.0.0.2/index.php?teams
- http://127.0.0.2/index.php?teams/&page=2
- http://127.0.0.2/index.php?teams/&page=3
- ...
- http://127.0.0.2/index.php?teams/&search=insertedSearchString
- http://127.0.0.2/index.php?teams/&page=2&search=insertedSearchString
- http://127.0.0.2/index.php?teams/&page=3&search=insertedSearchString
- ...
PHP:
<?php
class LoLCompetition_Route_PrefixPublic_Teams implements XenForo_Route_Interface
{
public function match($routePath, Zend_Controller_Request_Http $request, XenForo_Router $router)
{
$action = $router->resolveActionWithIntegerParam($routePath, $request, 'team_id');
$action = $router->resolveActionAsPageNumber($action, $request);
return $router->getRouteMatch('LoLCompetition_ControllerPublic_Teams', $action, 'lolcompetition');
}
public function buildLink($originalPrefix, $outputPrefix, $action, $extension, $data, array &$extraParams)
{
if($data && !empty($data['search'])){ $extraParams['search'] = $data['search']; }
$action = XenForo_Link::getPageNumberAsAction($action, $extraParams);
return XenForo_Link::buildBasicLinkWithIntegerParam($outputPrefix, $action, $extension, $data, "team_id", "name");
}
}
Important parts of the controller
PHP:
$options = XenForo_Application::get('options');
$perpage = $options->lolcompetition_teams_perpage;
$search = $this->_input->filterSingle('search', XenForo_Input::STRING);
$page = $this->_input->filterSingle('page', XenForo_Input::UINT);
$viewParams = array(
'teams' => $this->_getTeamsModel()->getTeams(/*...*/),
'perpage' => $perpage,
'totalTeams' => $this->_getTeamsModel()->getTeamCount(/*...*/),
'page' => $page
);
if($search){
$viewParams['search'] = array('search' => $search);
}
return $this->responseView("LoLCompetition_Teams_List", "lolcompetition_teams_list", $viewParams);