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

How do I use $_GET["something"] ?

Discussion in 'XenForo Development Discussions' started by PreFiX, Mar 17, 2015.

  1. PreFiX

    PreFiX Member

    Code:
    <?php
    
    class prefixaddon_Route_Prefix_Public implements XenForo_Route_Interface
    {
        public function match($routePath, Zend_Controller_Request_Http $request, XenForo_Router $router)
        {
            $action = $router->resolveActionWithStringParam($routePath, $request, 'string_id');
            $action = $router->resolveActionAsPageNumber($action, $request);
    
            $actions = explode('/', $action);
    
            switch ($actions[0])
            {
                case 'informacija':    $controller = 'Informacija';        break;
                default:            $controller = 'Pagrindinis';
            }
    
            return $router->getRouteMatch('prefixaddon_ControllerPublic_'.$controller, $action, 'paslaugos');
        }
    
        public function buildLink($originalPrefix, $outputPrefix, $action, $extension, $data, array &$extraParams)
        {
            $actions = explode('/', $action);
    
            switch ($actions[0])
            {
                case 'serveris':        $intParams = 'serveris_id';        $strParams = 'serveris_url';            break;
                case 'paslauga':        $intParams = 'paslauga_id';        $strParams = 'paslauga_url';            break;
            }
    
            $action = XenForo_Link::getPageNumberAsAction($action, $extraParams);
    
            if ($intParams)
            {
                return XenForo_Link::buildBasicLinkWithIntegerParam($outputPrefix, $action, $extension, $data, $intParams, $strParams);
            }
            else
            {
                return XenForo_Link::buildBasicLinkWithStringParam($outputPrefix, $action, $extension, $data, $strParams);
            }
        }
    }
    Hello, I'm novice. But I already did something with tutorials

    But I don't understand how do I should use $_GET["anything"] on xenforo any help?

    with link like http://example.com/Controller/Something.Value
    http://example.com/Controller/Something.Value/AnotherString.AnotherValue
     
  2. PreFiX

    PreFiX Member

    Anyone? :S
     
  3. Nobita.Kun

    Nobita.Kun Well-Known Member

    $value1 = $this->_input->filterSingle('input_key_name', 'input_key_type');

    For input_key_type, you should look XenForo_Input to get list of type XF supported.
     
  4. PreFiX

    PreFiX Member

    Hello, so would it make url like I mentioned? Thanks for reply :)
     
  5. Nobita.Kun

    Nobita.Kun Well-Known Member

    Not sure for it.
     
  6. Arty

    Arty Well-Known Member

    As I understand from your code, in array $actions first item is action, the rest are key.value combinations for parameters, right?

    Then use this in your router:

    Code:
    switch (array_shift($actions))
    {
       // your old code here
    }
    
    foreach ($actions as $pair)
    {
       $pair = explode('.', $pair, 2);
       if (count($pair) == 2)
       {
            $request->setParam($pair[0], $pair[1]);
       }
    }
    then in controller check input as @Nobita.Kun mentioned above
     
    Nobita.Kun likes this.
  7. PreFiX

    PreFiX Member

    I trying this thing for a while. But I can't still understand, it's not working for me at all. Can you give me full code of example of Router? and Controller?
     

Share This Page