We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
  • Hello,

    I'm trying to get a FURL redirect working with one of my CMPs but it's not sending any params to the landing page.

    My plugin which is set to OnPageNotFound. It does redirect fine so it is working but it's not sending the GET param to the next page. In the snippet on the next page, return $_GET['option1']; does not display anything. Funny thing is, this plugin works on the same server on a different domain... I've copied it over exactly and it's not working! Anyone able to help?

    <?php
    $context =  $modx->context->get('key');
    
    if($context == 'web'){
    
    $ResourceID = 60;
      
    $list = $modx->getService('list','List',$modx->getOption('list.core_path',null,$modx->getOption('core_path').'components/list/').'model/list/',$scriptProperties);
    if (!($list instanceof List)) return '';
    
      
    $search = $_SERVER['REQUEST_URI'];
    $base_url = $modx->getOption('base_url');
    if ($base_url != '/') {
        $search = str_replace($base_url,'',$search);
    }
    
    $search = trim($search, '/');
    $params = explode('/', $search);
      
    $title =  urldecode($params[2]);
    // url is similar to mysite.com/listing/list/article+3
    $c = $modx->newQuery('listDetail');
    $c->where(array(
      'active' => true,
      'title' =>   $title,
    ));
    
    $articles = $modx->getCollection('listDetail', $c);
    
    foreach($articles as $article){
    
    $_GET['option1'] = $article->get('option1');
     
    $modx->sendForward($ResourceID);
    return;
    }
    
    }
      Ross Sivills - MD AugmentBLU Edinburgh, Scotland UK
      AugmentBLU - MODX Partner

      BLUcart - MODX Revolution E-Commerce & Shopping Cart
    • What is option1? If that is a TV I don't think $article->get('option1') is what you expect it to be.
      • I have simplified the actual code but even if setting $_GET['option1'] = 'test'; still does not send the GET to the next page with a snippet expecting the GET.

        I had my page cached and snippet uncached, I now have the page uncached and the snippet uncached and it's now working. Is this the correct way to deal with the redirect and GET?

        If the page is cached or the snippet is then the GET does not work.

        Thanks!
          Ross Sivills - MD AugmentBLU Edinburgh, Scotland UK
          AugmentBLU - MODX Partner

          BLUcart - MODX Revolution E-Commerce & Shopping Cart
        • Show your snippet call from the landing page. I have several plugins like this that are working exactly as expected. Are you sure you are not using a cached snippet to retrieve the GET parameter value inside the outer uncached snippet call?
          • The snippet is simply

            $abc = $_GET['option1'];
            
            return $abc;


            Purely for testing... it would not show the GET if the page is cached or the snippet is cached. The snippet is just [[!testSnippet]] .

            If I return the $_GET['option1'] in the plugin, it does error but checking the log it does have the GET variable so it is there, just not being sent to the next page if I obviously don't return the variable in the plugin.
              Ross Sivills - MD AugmentBLU Edinburgh, Scotland UK
              AugmentBLU - MODX Partner

              BLUcart - MODX Revolution E-Commerce & Shopping Cart