On March 26, 2019 we launched new MODX Forums. Please join us at the new MODX Community Forums.
Subscribe: RSS
  • In the wiki http://wiki.modxcms.com/index.php/AjaxSearch is explained how to use this function, but i'am not able to do it...

    In the wiki:
    Line to add in the input layout template:
    <li><input type="radio" id="subSearch1" name="subSearch" value="travel,1" [+as.subSearch1Checked+] /><label for="subSearch1">Travel pictures gallery</label></li>



    Code to add to config file:
    function travel(){
         $config = array();
         // travel search definition
         $config['documents'] = '104';  
         $config['whereSearch'] = 'content:alias|jot|maxigallery';
         $config['extract'] = '0';
         $config['breadcrumbs'] = 'Breadcrumbs,showHomeCrumb:0,showCrumbsAtHome:1';
         return $config;
       }
    



    Modx encountered a error when add the function to config file:
    Cannot redeclare function travel() in .../assets/snippets/ajaxSearch/configs/default.config.php

    How can i solve it????
    many thx

    This question has been answered by coroico. See the first response.

      "Destiny is not a matter of chance, it's a matter of choice"
    • discuss.answer
      This is a classical php issue. Simply frame you function declaration with:

      if(!function_exists('travel')) {
      function travel(){
           $config = array();
           // travel search definition
           $config['documents'] = '104'; 
           $config['whereSearch'] = 'content:alias|jot|maxigallery';
           $config['extract'] = '0';
           $config['breadcrumbs'] = 'Breadcrumbs,showHomeCrumb:0,showCrumbsAtHome:1';
           return $config;
         }
      }

      By doing this you avoid a redeclaration.
      • This work great!!!!!!
        Many many thx!!

        For public use should update the wiki!! [ed. note: fabryshock last edited this post 8 years, 7 months ago.]
          "Destiny is not a matter of chance, it's a matter of choice"