We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 9359
    • 128 Posts
    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
      • 5811
      • 1,717 Posts
      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.
        • 9359
        • 128 Posts
        This work great!!!!!!
        Many many thx!!

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