How do we add parameters to getSessionActivityDetailsForList(array $activities)?

Jaxel

Well-known member
Using the following:
Code:
echo "<pre>";
print_r($activities);
exit;
This prints out the entire array and none of the array's "params" key has anything in them. Looking at other files in the XenForo base, they use passed variables in the params. How do I add my own?
 

Shadab

Well-known member
// Background Info.

The "params" key contains all parameters that were present in the Request object when viewing a XenForo powered page. By default it contains no parameters. During the routing process, when you "resolve" an action using any of the following methods (available in the Router object)
  • resolveActionWithIntegerParam()
  • resolveActionWithIntegerOrStringParam()
  • resolveActionWithStringParam()
  • resolveActionAsPageNumber()
...the parameter value is extracted from route path and added to the request object.
This extracted parameter can now be used:
  • In your controller, using the input filter ($this->_input->filter()).

  • In the getSessionActivityDetailsForList() method, as $activities[]['params']['your_parameter_name']
    But, unlike the input filtering process, a normal GET or POST parameter is not available here.
For example, 'thread_id' for thread views, 'node_name' for node pages, 'user_id' for user profiles, etc.

// Now

If you are not resolving actions using any of those 4 methods, in your route prefix class, you would find the params array to be empty. Is that the case for you?
 

Jaxel

Well-known member
Yeah, I'm just routing directly to index and doing the routing manually myself. Is there any way to get the action?
 

Shadab

Well-known member
Well, you really need to move the routing process to where it belongs: the Route Prefix Class.
 

Jaxel

Well-known member
Well I do it this way because so far I can't figure out how to route to "media/category". I can only route to "media".

This is my router:
Code:
<?php

class EWRmedio_Route_Media_Category implements XenForo_Route_Interface
{
	public function match($routePath, Zend_Controller_Request_Http $request, XenForo_Router $router)
	{
		$action = $router->resolveActionWithIntegerParam($routePath, $request, 'category_id');
		$action = $router->resolveActionAsPageNumber($action, $request);
		return $router->getRouteMatch('EWRmedio_ControllerPublic_Media_Category', $action, 'media_category');
	}

	public function buildLink($originalPrefix, $outputPrefix, $action, $extension, $data, array &$extraParams)
	{
		$outputPrefix = str_replace('_', '/', $outputPrefix);

		$action = XenForo_Link::getPageNumberAsAction($action, $extraParams);
		return XenForo_Link::buildBasicLinkWithIntegerParam($outputPrefix, $action, $extension, $data, 'category_id', 'category_name');
	}
}
It always routes to "EWRmedio_ControllerPublic_Media" instead of "EWRmedio_ControllerPublic_Media_Category".

This is because going to "media/category" will ALWAYS route to the "media" router.
 

Mike

XenForo developer
Staff member
The params will consist of things pushed into the request via $request->setParam().
 
Top