We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 42212
    • 14 Posts
    I'm create plugin on OnPageNotFound event and check in url id of custom faq element.
    That url: /faq/7548.html and need display page: /faq/?faq=7548
    Without .htaccess, if use .htaccess some string: RewriteRule ^faq/([0-9]+)\.html$ faq/?faq=$1

    $modx->sendForward($id); gets integer id of resource, how make sendForward to id of resource and with $_GET variable, as:
    /faq/?faq=7548
    having 7548 value?

    It's a really? Thank you very much!
      • 4172
      • 5,888 Posts
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 33976 ☆ A M B ☆
        • 571 Posts
        Hi,

        Seems like sendForward does not allow passing that kind of parameters.
        I assume that's because you want to get that parameter and use it in a snippet.

        If so, why not making use of a placeholder ?
        $modx->setPlaceholder('faq', 'your-value');
        $modx->sendForward($id);
        

        and in your resource you would use your snippet to retrieve your faq item
        [[!snippet? &faq=`[[!+faq]]`]]
        


        Hope it makes sense

        Edit : or what Bruno wrote, seems even better and would prevent some parsing ^^ Nice catch
          • 42212
          • 14 Posts
          Thank you!
          It was very simple!
          Plugin:
          <?php
          
          if ($modx->event->name == 'OnPageNotFound') {
              $uri = $_SERVER['REQUEST_URI'];
              if(strpos($uri, 'faq/')){
                  if(preg_match("#\/faq\/(\d+)\.html#i",$uri,$uriMatches)){
                      $faqId = $uriMatches[1];
                      $_GET['faq'] = $faqId;
                      $modx->sendForward(258);
                  }
              }
          }


          And in snippet in content on resource 258 $faqId available in $_GET['faq']!