We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 8190
    • 21 Posts
    Hi,

    I’m trying to customize the ajaxseach snippet.
    Standard it’s only possible to search pages and page-content.
    I want the visitor also to be able to search for webusers.
    I tried to build it in, but without any succes.

    I managed to get the ’x results found’-message, but the results didn’t show.
    Enother problem was the snippet only searched page-content or users, not both at the same time.
    Is there an easy whay to do this, maybe another search snippet?

    Thanx for the help.
    Marc
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Are you trying to allow access to a user’s profile? I think WebLoginPE in ’users’ mode would be closer to what you want. It wouldn’t be too difficult to add a user search feature to that. It has a "ViewUserProfile( string $username )" function that should be useful.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 5811
        • 1,717 Posts
        I want the visitor also to be able to search for webusers.
        Another problem was the snippet only searched page-content or users, not both at the same time.
        Is there an easy whay to do this,

        To customize ajaxSearch to do a search in the webuser table you should redefine the search by using the whereSearch parameter. Something like &whereSearch=`webusers` &config=`webusersCfg

        with the webusersCfg file content:
        <?php
        
        function webusers(& $main,& $joined, $listIDs){
        
          $main = array(
              'tb_name' => "modx_web_users",
              'tb_alias' => 'mwu',
              'id' => 'id',
              'searchable' => array('username'),
              'displayed' => array('username'),
              'date' =>array(),
              'filters' => array(),
              'jfilters'  => array()
            );
            
          $main['filters'][]= array();
          
          $main['filters'][]= array();
           
          $joined = NULL;
        }
        
        ?>`
        With this, you couldn’t, in the same search, do a search in the web_users table and in the document content.
        You couldn’t because it doesn’t exist a link between a document and a web user.

        But if needed you could the subSearch to set up a form which allow a search in documents or in web users list.

        See: http://www.modx.wangba.fr/index.php?id=264 for subSearch
        See: http://modxcms.com/forums/index.php/topic,34002.msg207346.html#msg207346 as example for a search in a wordpress table