SNK
Member
Hello,
Firstly, I'm French and sorry for my bad english.
I want to create a route with two integer, exemple :
But I can't do this, for the moment I have :
My xenForo's Route :
Of course, I have replaced the values with my personnal values, it just the name of XX_id who change.
---
I know it is possible, like "http://8wayrun.com/rankings/thermidor.2162/user/1"
Thanks,
Benjamin.
Firstly, I'm French and sorry for my bad english.
I want to create a route with two integer, exemple :
Code:
https://mysite.com/module/first_id/users/second_id/action
But I can't do this, for the moment I have :
Code:
https://mysite.com/module/users/first_id/second_id/action
My xenForo's Route :
PHP:
public function match($routePath, Zend_Controller_Request_Http $request, XenForo_Router $router)
{
$components = explode('/', $routePath);
$subPrefix = strtolower(array_shift($components));
$subSplits = explode('.', $subPrefix);
$controllerName = '';
$action = '';
$intParams = '';
$strParams = '';
$slice = false;
switch ($subPrefix)
{
case 'add':
$controllerName = '_Add';
$slice = true;
break;
case 'users':
$controllerName = '_Users';
$slice = true;
$request->setParam('first_id', array_shift($components));
$request->setParam('second_id', array_shift($components));
break;
default :
$controllerName = '_Index';
$intParams = 'first_id';
}
$routePathAction = ($slice ? implode('/', array_slice($components, 0, 2)) : $routePath).'/';
$routePathAction = str_replace('//', '/', $routePathAction);
if ($strParams)
{
$action = $router->resolveActionWithStringParam($routePathAction, $request, $strParams);
}
else
{
$action = $router->resolveActionWithIntegerParam($routePathAction, $request, $intParams);
}
$action = $router->resolveActionAsPageNumber($action, $request);
return $router->getRouteMatch('MyModule_ControllerPublic'.$controllerName, $action, 'module_name', $routePath);
}
/**
* Method to build a link to the specified page/action with the provided
* data and params.
* @see XenForo_Route_BuilderInterface
*/
public function buildLink($originalPrefix, $outputPrefix, $action, $extension, $data, array &$extraParams)
{
$components = explode('/', $action);
$subPrefix = strtolower(array_shift($components));
$intParams = '';
$strParams = '';
$title = '';
$slice = false;
switch ($subPrefix)
{
case 'add':
$slice = true;
break;
case 'users':
$intParams = 'second_id';
$slice = true;
break;
default: $intParams = 'first_id'; $title = 'title';
}
if ($slice)
{
$outputPrefix .= '/'.$subPrefix;
$action = implode('/', $components);
}
$action = XenForo_Link::getPageNumberAsAction($action, $extraParams);
if ($strParams)
{
return XenForo_Link::buildBasicLinkWithStringParam($outputPrefix, $action, $extension, $data, $strParams);
}
else
{
return XenForo_Link::buildBasicLinkWithIntegerParam($outputPrefix, $action, $extension, $data, $intParams, $title);
}
}
Of course, I have replaced the values with my personnal values, it just the name of XX_id who change.
---
I know it is possible, like "http://8wayrun.com/rankings/thermidor.2162/user/1"
Thanks,
Benjamin.