• subSearch user function [Solved]#

  • FabryShock Reply #1, 7 months, 1 week ago

    Reply
    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


  • coroico Reply #2, 7 months, 1 week ago

    Reply
    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.


  • FabryShock Reply #3, 7 months, 1 week ago

    Reply
    This work great!!!!!!
    Many many thx!!

    For public use should update the wiki!!