corbitWire1
Member
My adventure into the beautiful system of xenForo continues:
I've overriden XenForo_Route_Prefix_Threads and XenForo_ControllerPublic_Thread. Actually I am trying to modify the behavior of XenForo_ControllerPublic_Thread and I need to support one additional URL parameter named 'apage'. That's why I've overriden XenForo_Route_Prefix_Threads.
My class (which overrides XenForo_Route_Prefix_Threads) contains the following code:
It should work on a URL like index.php?threads/this-is-a-test.5/apage-2. The regex code works correctly as it is almost the same code xenForo uses to handle /page-id URL patterns. If I uncomment the 'die' line, the requested apage value get's displayed. That means that the regex works and the apage param get's set correctly. The problem is that the value of apage isn't available to my controller (my controller reports a value of 0 all the time). If I set the apage parameter to a hardcoded value as I've done in the commented line, everything works like a charm. My controller fetches the apage value by using
Why my hardcoded apage value works while the URL's one doesn't?
I've overriden XenForo_Route_Prefix_Threads and XenForo_ControllerPublic_Thread. Actually I am trying to modify the behavior of XenForo_ControllerPublic_Thread and I need to support one additional URL parameter named 'apage'. That's why I've overriden XenForo_Route_Prefix_Threads.
My class (which overrides XenForo_Route_Prefix_Threads) contains the following code:
PHP:
public function match($routePath, Zend_Controller_Request_Http $request, XenForo_Router $router)
{
$action = $router->resolveActionWithIntegerParam($routePath, $request, 'thread_id');
$action = $router->resolveActionAsPageNumber($action, $request);
// Handle article pages
if (preg_match('#^apage-(\d+)$#i', $action, $match))
{
$action = '';
$request->setParam('apage', $match[1]);
//die ($request->getParam('apage'));
}
//$request->setParam('apage', 1);
return $router->getRouteMatch('XenForo_ControllerPublic_Thread', $action, 'forums');
}
It should work on a URL like index.php?threads/this-is-a-test.5/apage-2. The regex code works correctly as it is almost the same code xenForo uses to handle /page-id URL patterns. If I uncomment the 'die' line, the requested apage value get's displayed. That means that the regex works and the apage param get's set correctly. The problem is that the value of apage isn't available to my controller (my controller reports a value of 0 all the time). If I set the apage parameter to a hardcoded value as I've done in the commented line, everything works like a charm. My controller fetches the apage value by using
PHP:
$apage = max(0, $this->_input->filterSingle('apage', XenForo_Input::UINT));
Why my hardcoded apage value works while the URL's one doesn't?