We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
  • I’m must be missing something here.
    I’ve created my own custom DB search, but also still using AjaxSearch for the website retrieval.
    I’m trying to make a radio button so the search text input will have ’search in website’ (AjaxSearch) and ’search in database’ (custom).
    But the searchSwitcher snippet does not work (the custom search engine does work, and it is not the topic).

    <?php
    include_once(MODX_MANAGER_PATH.'includes/document.parser.class.inc.php');
    
    if (isset($_POST['searchswitchersubmit'])) {
        if ($_POST['searchswitcherradio']=='database') {
            return $modx->runSnippet("sgpidbsearch",array(
                "search"=>$_POST['searchtext']
                ));
        }
        if ($_POST['searchswitcherradio']=='website') {
            return $modx->runSnippet("AjaxSearch",array(
                "ajaxSearch"=>'0'
                ,"landingPage"=>'42'
                ,'advSearch'=>'allword'
                ,"search"=>$_POST['searchtext']
                ));
        }
    }
    ?>
    <html>
    
    <form id="searchswitcher" action="<?php echo $_SERVER['php_self']?>" class="searchswitcher" method="POST">
        <span class="searchtext">Quick search here: </span> <input type="text" size="" name="searchtext" /><br />
        <input type="radio" name="searchswitcherradio" value="database" checked="checked"> in database  
        <input type="radio" name="searchswitcherradio" value="website"> in website  
        <input type="submit" name="searchswitchersubmit" value="Search" />
    </form>
    
    </html>
    


    Do you have any idea where my fault is?

    Thanks ahead.
      Rico
      Genius is one percent inspiration and ninety-nine percent perspiration. Thomas A. Edison
      MODx is great, but knowing how to use it well makes it perfect!

      www.virtudraft.com

      Security, security, security! | Indonesian MODx Forum | MODx Revo's cheatsheets | MODx Evo's cheatsheets

      Author of Easy 2 Gallery 1.4.x, PHPTidy, spieFeed, FileDownload R, Upload To Users CMP, Inherit Template TV, LexRating, ExerPlan, Lingua, virtuNewsletter, Grid Class Key, SmartTag, prevNext

      Maintainter/contributor of Babel

      Because it's hard to follow all topics on the forum, PING ME ON TWITTER @_goldsky if you need my help.
    • nevermind.
      I come up with this solution:

      <?php
      if (isset($_POST['searchswitchersubmit'])) {
          if ($_POST['searchswitcherradio']=='database') {
              header('location: '.MODX_BASE_URL.'index.php?id=43&search='.$_POST['searchtext']);
          }
          if ($_POST['searchswitcherradio']=='website') {
              header('location: '.MODX_BASE_URL.'index.php?id=42&search='.$_POST['searchtext']);
          }
      }
      ?>
      <form id="searchswitcher" action="<?php echo $_SERVER['php_self']?>" class="searchswitcher" method="POST">
          <span class="like_h2">Quick search here: </span> <input type="text" size="" name="searchtext" /><br />
          <input type="radio" name="searchswitcherradio" value="database" checked="checked"> in database  
          <input type="radio" name="searchswitcherradio" value="website"> in website  
          <input type="submit" name="searchswitchersubmit" value="Search" />
      </form>
      
        Rico
        Genius is one percent inspiration and ninety-nine percent perspiration. Thomas A. Edison
        MODx is great, but knowing how to use it well makes it perfect!

        www.virtudraft.com

        Security, security, security! | Indonesian MODx Forum | MODx Revo's cheatsheets | MODx Evo's cheatsheets

        Author of Easy 2 Gallery 1.4.x, PHPTidy, spieFeed, FileDownload R, Upload To Users CMP, Inherit Template TV, LexRating, ExerPlan, Lingua, virtuNewsletter, Grid Class Key, SmartTag, prevNext

        Maintainter/contributor of Babel

        Because it's hard to follow all topics on the forum, PING ME ON TWITTER @_goldsky if you need my help.