We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 18367
    • 834 Posts
    I have a Wordpress blog alongside my Modx site and I was wondering if Ajax search can be configured to search the blog as well?

    grin
      Content Creator and Copywriter
      • 5811
      • 1,717 Posts
      AjaxSearch could be used with your own custom tables. So it depends mainly of the structure of the wordpress tables.
      The wordpress tables should be in the same database as Modx. Let me know in which tables of wordpress you want search, give me the sql order to set these tables and in which fields you would like do a search.
        • 18367
        • 834 Posts
        Coroico,

        thanks for the quick response, although all this talk about sql makes me queasy.

        Anyhow, the wp blog is under the same domain as modx, however the blog is in a sub folder.

        As for being in the same database, I’ve never quite understood some of the distinctions used.

        I access it thru phpadmin, and in the drop down list it gives me my main database (?) and then two sub dbs underneath it. (modx and wp)

        IE: Main db
        _modx
        _wp

        (For security reasons, these aren’t the actual names but you get the idea.)


        The table I want to search is wp_posts (I think)

        Does that help?




          Content Creator and Copywriter
          • 18367
          • 834 Posts
          Wow,

          thanks for this Coroico.

          This should keep me busy for awhile.

          I had the Wordpress blog as a separate blog on my site before I discovered Modx.

          It’s good to know about keeping everything in the same database.

          One day, if I ever get time, I might see if I can shift the wp tables into Modx. Then again I might not, depends how complicated it gets.

          Thanks again.

            Content Creator and Copywriter
            • 8883
            • 59 Posts
            Hi,
            I realized a specific table-search with your instructions. All fine. Thanks.

            But is it possible to "merge" the search?
            I want to search in two or more tables (owntable and the modx-tables) at the same time, not neither nor as it provided by the &subSearch-parameter.

            e.g.: &whereSearch=`content|owntable` will cause an issue, you said it already.
            The &order-param; &order=``columnofowntable,...` cause a SQL-Error (order by unknown columns)

            Any idea?
            Ok. Two search-forms, but thats not gratifying.
              • 5811
              • 1,717 Posts
              But is it possible to "merge" the search?
              I want to search in two or more tables (owntable and the modx-tables) at the same time
              With the version 1.8.1 it is possible to search in several tables (modx or owntable) BUT the limitation are the followings:

              - only one "main" table, which could be a modx table or a owntable. For instance "site_content" or "posts" for wordpress example.
              - several "joined" tables (modx or not).

              The "maxigallery" table is a good example of "joined" table. here is the extract of classes/search.class.inc.php file - initSearchContext function :
              case ’maxigallery’:
              $this->joined[] = array(
              ’tb_name’ => $this->getShortTableName(’maxigallery’),
              ’tb_alias’ => ’gal’,
              ’id’ => ’id’,
              ’main’ => ’id’,
              ’join’ => ’gal_id’,
              ’searchable’ => array(’title’,’descr’),
              ’displayed’ => array(’title’,’descr’,’filename’),
              ’concat_separator’ => ’, ’,
              ’filters’ => array()
              );
              The maxigallery as a joined table has a "join" key (= gal_id) used to do the link with the "main" key (= id) of the main table (site_content).
              The list of searchable fields of the maxigallery table are provided by the key "searchable"
              The list of viewable fields of the maxigallery table are provided by the key "displayed".
              I want to search in two or more tables
              are these tables joined or not ?
              Could you send me by PM your mysql structure tables and the fields you would like search in.

              I could examine the feasability to use several " main" tables but this will imply to add the name of "main" in each "joined table.
                • 4370
                • 13 Posts
                Hi,
                I’m trying to run non-ajax simple search with own tables, and got just output - list of ALL rows from the table. Btw, filter works and those rows didn’t appear. I really have no idea, what is the problem. Using different tables, changing code...

                Table: just like "ext_products" from example

                catalog.config.php
                <?php

                function catalog(& $main,& $joined, $listIDs){

                $main = array(
                ’tb_name’ => "ext_products",
                ’tb_alias’ => ’catalias’,
                ’id’ => ’id’,
                ’searcheable’ => array(’name’,’description’),
                ’displayed’ => array(’id’,’name’,’description’),
                ’date’ => array(),
                ’filters’ => array(),
                ’jfilters’  => array()
                );
                   
                $main[’filters’][]= array(
                ’field’ => ’available’,
                ’oper’ => ’=’,
                ’value’ => "1"
                );
                 
                    $joined = NULL;
                }

                ?>

                Snippet call:
                [!AjaxSearch? &ajaxSearch=`0` &whereSearch=`catalog` &config=`catalog` &tplResult=`@FILE:assets/snippets/ajaxSearch/templates/catalogresult.tpl.html`  &order=`id` highlight=`1` &AS_landing=`33` &extract=`0`!]


                Input: something like "unrealtexttt"
                Result: All items except "available=0"

                Could it be problem of database settings or something else? Just simple testsearch works fine, so it is just for sql table.
                Many thanks for any help.
                  • 5811
                  • 1,717 Posts
                  Could you add &debug=`3` and post the content of the debug file : snippets/ajaxSearch/ajaxSearch_log.txt gotten just after searching something.

                  Could you add the sql definition of your ext_products table. Thanks.
                    • 4370
                    • 13 Posts
                    Here we are:
                    [2-Jun-09 01:07:31]  AjaxSearch 1.8.1 - Php5.2.9 - MySql 5.0.77-log
                    [2-Jun-09 01:07:31]  AjaxSearch - Configuration file catalog : 
                    <?php
                    
                    function catalog(& $main,& $joined, $listIDs){
                    
                      $main = array(
                          'tb_name' => "ext_products",
                          'tb_alias' => 'catalias',
                          'id' => 'id',
                          'searcheable' => array('name','description'),
                    	  'displayed' => array('id','name','description'),
                    	  'date' => array(),
                          'filters' => array(),
                          'jfilters'  => array()
                        );
                        
                       $main['filters'][]= array(
                        'field' => 'available',
                        'oper' => '=',
                        'value' => "1" 
                      );
                      
                        $joined = NULL;
                    }
                    
                    ?>
                    [2-Jun-09 01:07:31]  AjaxSearch - User configuration - Before parameter checking : Array
                    (
                        [config] => catalog
                        [version] => 1.8.1
                        [debug] => 3
                        [language] => russian-UTF8
                        [ajaxSearch] => 0
                        [advSearch] => oneword
                        [whereSearch] => catalog
                        [subSearch] => 5,1
                        [withTvs] => 
                        [order] => id
                        [rank] => pagetitle:100,extract
                        [minChars] => 3
                        [AS_showForm] => 1
                        [resultsPage] => 0
                        [grabMax] => 10
                        [extract] => 0
                        [extractLength] => 200
                        [extractEllips] => ...
                        [extractSeparator] => <br />
                        [formatDate] => d/m/y : H:i:s
                        [highlightResult] => 1
                        [pageLinkSeparator] =>  | 
                        [AS_landing] => 33
                        [AS_showResults] => 1
                        [idType] => parents
                        [parents] => 
                        [documents] => 
                        [depth] => 10
                        [hideMenu] => 2
                        [hideLink] => 1
                        [filter] => 
                        [tplLayout] => @FILE:assets/snippets/ajaxSearch/templates/cataloglayout.tpl.html
                        [tplResults] => @FILE:assets/snippets/ajaxSearch/templates/results.tpl.html
                        [tplResult] => @FILE:assets/snippets/ajaxSearch/templates/catalogresult.tpl.html
                        [tplPaging] => @FILE:assets/snippets/ajaxSearch/templates/paging.tpl.html
                        [stripInput] => defaultStripInput
                        [stripOutput] => defaultStripOutput
                        [searchWordList] => 
                        [breadcrumbs] => 0
                        [tvPhx] => 0
                        [clearDefault] => 0
                        [jsClearDefault] => assets/snippets/ajaxSearch/js/clearDefault.js
                    )
                    
                    [2-Jun-09 01:07:31]  AjaxSearch - tplResult template @FILE:assets/snippets/ajaxSearch/templates/catalogresult.tpl.html : <div class="[+as.nameClass+]">
                    	<p>[+as.id+] --- [+as.name +]-------[+as.description+]</p>
                    </div>
                    [2-Jun-09 01:07:31]  AjaxSearch - tplResults template@FILE:assets/snippets/ajaxSearch/templates/results.tpl.html : [+as.noResults:is=`1`:then=`
                      <div class="[+as.noResultClass+]">
                        [+as.noResultText+]
                      </div>
                    `:else=`
                      <p class="ajaxSearch_resultsInfo">[+as.resultInfoText+]</p>
                      [+as.paging+]
                      [+as.listResults+]
                      [+as.paging+]
                    `+]
                    [2-Jun-09 01:07:31]  AjaxSearch - tplResult template@FILE:assets/snippets/ajaxSearch/templates/cataloglayout.tpl.html : [+as.showForm:is=`1`:then=`
                    <form [+as.formId+] action="[+as.formAction+]" method="post">
                        <fieldset>		
                        <label for="ajaxSearch_input">
                          <input id="ajaxSearch_input" class="cleardefault" type="text" name="search" value="[+as.inputValue+]"[+as.inputOptions+] />
                        </label>
                        <label for="ajaxSearch_submit">
                          <input id="ajaxSearch_submit" type="submit" name="sub" value="[+as.submitText+]" />
                        </label>
                        </fieldset>
                    </form>
                    `+]
                    [+as.showIntro:is=`1`:then=`
                    <p class="ajaxSearch_intro" id="ajaxSearch_intro">[+as.introMessage+]</p>
                    `+]
                    [+as.showResults:is=`1`:then=`
                    [+as.results+]
                    `+]
                    [2-Jun-09 01:07:31]  AjaxSearchPopup - User configuration - Before doSearch : Array
                    (
                        [config] => catalog
                        [version] => 1.8.1
                        [debug] => 3
                        [language] => russian-UTF8
                        [ajaxSearch] => 0
                        [advSearch] => oneword
                        [whereSearch] => catalog
                        [subSearch] => 5,1
                        [withTvs] => 
                        [order] => id
                        [rank] => pagetitle:100,extract
                        [minChars] => 3
                        [AS_showForm] => 1
                        [resultsPage] => 0
                        [grabMax] => 10
                        [extract] => 0:content
                        [extractLength] => 200
                        [extractEllips] => ...
                        [extractSeparator] => <br />
                        [formatDate] => d/m/y : H:i:s
                        [highlightResult] => 1
                        [pageLinkSeparator] =>  | 
                        [AS_landing] => 33
                        [AS_showResults] => 1
                        [idType] => parents
                        [parents] => 
                        [documents] => 
                        [depth] => 10
                        [hideMenu] => 2
                        [hideLink] => 1
                        [filter] => 
                        [tplLayout] => @FILE:assets/snippets/ajaxSearch/templates/cataloglayout.tpl.html
                        [tplResults] => @FILE:assets/snippets/ajaxSearch/templates/results.tpl.html
                        [tplResult] => @FILE:assets/snippets/ajaxSearch/templates/catalogresult.tpl.html
                        [tplPaging] => @FILE:assets/snippets/ajaxSearch/templates/paging.tpl.html
                        [stripInput] => defaultStripInput
                        [stripOutput] => defaultStripOutput
                        [searchWordList] => 
                        [breadcrumbs] => 0
                        [tvPhx] => 0
                        [clearDefault] => 0
                        [jsClearDefault] => assets/snippets/ajaxSearch/js/clearDefault.js
                        [listIDs] => 
                        [docgrp] => 
                    )
                    
                    [2-Jun-09 01:07:31]  Search context main ext_products : Array
                    (
                        [tb_name] => ext_products
                        [tb_alias] => catalias
                        [id] => id
                        [searcheable] => Array
                            (
                                [0] => name
                                [1] => description
                            )
                    
                        [displayed] => Array
                            (
                                [0] => id
                                [1] => name
                                [2] => description
                            )
                    
                        [date] => Array
                            (
                            )
                    
                        [filters] => Array
                            (
                                [0] => Array
                                    (
                                        [field] => available
                                        [oper] => =
                                        [value] => 1
                                    )
                    
                            )
                    
                        [jfilters] => Array
                            (
                            )
                    
                    )
                    
                    [2-Jun-09 01:07:31]  Select :  
                    SELECT catalias.id, catalias.id, catalias.name, catalias.description 
                    FROM ext_products catalias 
                    WHERE ((catalias.available=1)) 
                    GROUP BY catalias.id 
                    HAVING 1 
                    ORDER BY catalias.id
                    [2-Jun-09 01:07:31]  AjaxSearch - tplResult template @FILE:assets/snippets/ajaxSearch/templates/paging.tpl.html : [+as.tpl:is=`paging`:then=`
                      <span class="ajaxSearch_paging">
                        [+as.pagingText+]
                        [+as.pagingLinks+]
                      </span>
                    `+]
                    [+as.tpl:is=`pagingLinks`:then=`
                      <a href="[+as.pagingLink+]">[+as.pagingText+]</a>[+as.pagingSeparator+]
                    `+]
                    [+as.tpl:is=`pagingLinksCurrent`:then=`
                      [+as.pagingText+][+as.pagingSeparator+]
                    `+]
                    [2-Jun-09 01:07:31]  AjaxSearchPopup - Output results before ranking : Array
                    (
                        [id] => 2
                        [name] => Iphone 3G
                        [description] => Though there are still some big features missing from the iPhone, the addition of 3G and GPS, the affordable price tag, and extra features from the iPhone 2.0 software update make the handset a worthy prospect.
                        [extract] => 
                    )
                    
                    [2-Jun-09 01:07:31]  AjaxSearchPopup - Output results before ranking : Array
                    (
                        [id] => 3
                        [name] => Palm Treo 750
                        [description] => A bevy of OS enhancements and access to Telstra's Next G mobile broadband network easily make the Treo 750 the best Windows Mobile device we've ever used.
                        [extract] => 
                    )
                    
                    [2-Jun-09 01:07:31]  AjaxSearchPopup - Output results before ranking : Array
                    (
                        [id] => 4
                        [name] => Nokia E90
                        [description] => Nokia's E90 smartphone is the latest in the Communicator series, featuring HSDPA support, inbuilt GPS and Wi-Fi.
                        [extract] => 
                    )
                    
                    ........................


                    Database was created using definition from example, just copy. Or you need export file? Thx.
                      • 18402
                      • 6 Posts
                      Thanks for that Wiki coroico.
                        www.01241.com