We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 44231
    • 126 Posts
    Hi there can you give me a hand in my building a search engine for my website
    Im using Advsearch and I want to search into my custom tables I already read the documentation of the Advsearch but it really confuse me

    Do have any pointers for me to accomplish this manner?

    all reply will much appreciated thanks!

    And also I'm new in modx
    Im using modx 2.2.6 pl traditional..
      • 9207 ☆ A M B ☆
      • 2,475 Posts
      Consider upgrading to the latest version of MODX, or at a minimum, install the security patch.

      I don't think AdvSearch was built to search custom tables -- it's just for searching the built-in MODX tables. With some PHP knowledge, though, you could modify it to build queries on the custom tables.
        • 44231
        • 126 Posts
        I've tried the custom package tuts of the Advsearch but no luck
        NO result was display and also NO errors was also display in error logs

        what do you think is the problem?

        Ive tried different search

        Simple search
        Advsearch
        and a search made by xpdo criteria but this option was very slow
          • 44231
          • 126 Posts
          when I run my custom hook this always the error
          I don't know if it is connected to the Advsearch or my configuration in localhost

          [2013-07-17 06:59:40] (ERROR @ /index.php) `` is not a valid integer and may not be passed to makeUrl()
          [2013-07-17 06:59:40] (ERROR @ /index.php) [OnWebPagePrerender]<br />
          <b>Notice</b>:  Undefined property: modX::$documentIdentifier in <b>C:\tfv\public_html\core\cache\includes\elements\modplugin\9.include.cache.php</b> on line <b>10</b><br />
          <br />
          <b>Notice</b>:  Undefined property: modX::$documentOutput in <b>C:\tfv\public_html\core\cache\includes\elements\modplugin\9.include.cache.php</b> on line <b>10</b><br />
            • 37210
            • 131 Posts
            Hi John,

            I don't know if you still need help with this, but I just ended up making my own very simple search engine that searches through the gallery_item table and spits out the results. If you don't know much PHP, let me know, then I'll walk you through the steps.

            Go to my other post where Sottwell helped me out:
            https://forums.modx.com/thread/85797/back-to-php-basics-how-do-you-echo-a-gallery-snippet-call-within-a-custom-snippet#dis-post-472956

            Why I chose not to use AdvSearch or SimpleSearch
            I gave up on AdvSearch and SimpleSearch because I realized (after way too long) that you CAN'T get any kind of search result from the gallery tables, because AS and SS need to return a RESOURCE URL. I didn't want this, what I wanted, was to simply return the gallery items, one by one, each as a search result and then maybe when you click on the link, it simply goes to a blown up version of the image. Get it? I wouldn't be surprised if you don't, coz it took me ages to even figure out that I couldn't use AdvSearch or SimpleSearch.

            However, you can use AdvSearch...
            On the other hand, you can use Zend library in AdvSearch. Check out my reply (#4) here: https://forums.modx.com/thread/84414/best-search-snippet-to-search-through-gallery#dis-post-470571. This option didn't work for me because:

            • I had to run the indexation.php (to read through the front-end resources in my site tree) script everytime I added an item to a gallery album
            • When a result was returned, it didn't return the gallery item. It would return the resource that the gallery item was in, which meant that the web user is shown a whole album. This might be confusing because if they only wanted to find one image within the gallery, they'd have to flick through my slideshow just to find it.

            Confusing enough?
            :P
            Sar
              • 44231
              • 126 Posts
              we have the same problem here thanks for the info I'm sure I will be needing this information for future changes in my website. thanks for making a time to get back on me!!


              cheers!
                • 37210
                • 131 Posts
                Quote from: johnrobert27 at Jul 25, 2013, 09:02 PM
                we have the same problem here thanks for the info I'm sure I will be needing this information for future changes in my website. thanks for making a time to get back on me!!
                cheers!

                Sorry I couldn't get back to you earlier. I hope you can manage to get custom hooks working though. That might be a better solution if you can get it up and running. But I gave up and just had to make my own simple search engine.

                Sar
                  • 5811
                  • 1,717 Posts
                  Apologies, the links to AdvSearch queryhooks files of "search in custom packages" demos were wrong. This is now corrected.

                  To run a search in custom tables, look at the queryhook files of demos:

                  http://www.revo.wangba.fr/custom-package-dvd-shop/
                  http://www.revo.wangba.fr/custom-package-dvd-shop-2/

                  Hope this help you.
                    • 37210
                    • 131 Posts
                    Quote from: coroico at Jul 26, 2013, 07:48 AM
                    Apologies, the links to AdvSearch queryhooks files of "search in custom packages" demos were wrong. This is now corrected.

                    To run a search in custom tables, look at the queryhook files of demos:

                    http://www.revo.wangba.fr/custom-package-dvd-shop/
                    http://www.revo.wangba.fr/custom-package-dvd-shop-2/

                    Hope this help you.

                    Hi Coroico,

                    I hope this helps out johnrobert27 smiley

                    Just for my situation though, I've had a look at the demo dvdqhook.snippet.php text file, and I'm wondering what class I would put for the Gallery table.....or is it definitely not possible?

                    $main = array(
                        'package' => 'gallery',
                        'packagePath' => '{core_path}components/gallery/model/',
                        'class' => '????',


                    My AdvSearch call would look like this on the landing page:

                    [[!AdvSearch? &queryHook=`galleryHook`]]


                    Thanks!
                    Sar
                      • 5811
                      • 1,717 Posts
                      The class name depend of your package.

                      As exemple hereafter is the dvd package:
                      <?xml version="1.0" encoding="UTF-8"?>
                      <model package="dvd" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM" version="1.1">
                      	<object class="dvdCategories" table="dvd_categories" extends="xPDOSimpleObject">
                      		<field key="name" dbtype="varchar" precision="255" phptype="string" null="true" />
                      		<field key="description" dbtype="mediumtext" phptype="string" null="true" />
                      	</object>
                      	<object class="dvdProducts" table="dvd_products" extends="xPDOSimpleObject">
                      		<field key="code" dbtype="char" precision="25" phptype="string" null="true" />
                      		<field key="category_id" dbtype="int" precision="11" phptype="integer" null="true" index="index" />
                      		<field key="name" dbtype="varchar" precision="255" phptype="string" null="true" />
                      		<field key="tags" dbtype="varchar" precision="200" phptype="string" null="true" />
                      		<field key="price" dbtype="float" phptype="float" null="true" />
                      		<field key="weight" dbtype="float" phptype="float" null="true" />
                      		<field key="image" dbtype="varchar" precision="30" phptype="string" null="true" />
                      		<field key="image_thmb" dbtype="varchar" precision="30" phptype="string" null="true" />
                      		<field key="in_stock" dbtype="int" precision="11" phptype="integer" null="true" />
                      		<field key="enabled" dbtype="int" precision="1" phptype="integer" null="false" default="1" />
                      		<field key="studio" dbtype="varchar" precision="30" phptype="string" null="true" />
                      		<field key="production_year" dbtype="varchar" precision="30" phptype="string" null="true" />
                      		<field key="release_date" dbtype="int" precision="11" phptype="integer" null="true" />
                      		<field key="length" dbtype="float" phptype="float" null="true" />
                      		<field key="description" dbtype="mediumtext" phptype="string" null="true" />
                      
                      		<index alias="category_id" name="category_id" primary="false" unique="false" type="BTREE" >
                      			<column key="category_id" length="" collation="A" null="true" />
                      		</index>
                      	</object>
                      </model>


                      For the dvd shop demo, the queryHook works with the class dvdProducts:
                      $main = array(
                          'package' => 'dvd',
                          'packagePath' => '{core_path}components/dvd/model/',
                          'class' => 'dvdProducts',