1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

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

Discussion in 'XenForo Development Discussions' started by Jaxel, Feb 27, 2011.

  1. Jaxel

    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?
     
  2. Jaxel

    Jaxel Well-Known Member

    Any word on this?
     
  3. Shadab

    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?
     
    Kier likes this.
  4. Jaxel

    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?
     
  5. Shadab

    Shadab Well-Known Member

    Well, you really need to move the routing process to where it belongs: the Route Prefix Class.
     
  6. Jaxel

    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.
     
  7. Mike

    Mike XenForo Developer Staff Member

    The params will consist of things pushed into the request via $request->setParam().
     

Share This Page