We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
  • You should be able to add the Template select to the MIGXdb configuration, but that's way beyond my skill level.
      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
      • 4172
      • 5,888 Posts
      instaed of using inputTVtype: hidden for the template, you can use

      inputTVtype: listbox
      input option values: @CHUNK templateListbox

      the chunk templateListbox:

      Select Template==||
      [[migxLoopCollection?
      &classname=`modTemplate`
      &tpl=`@CODE:[[+templatename]]==[[+id]]`
      &outputSeparator=`||`
      &sortConfig=`[{"sortby":"templatename"}]`
      ]]




        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 30585
        • 833 Posts
        Bruno, you really know your stuff.

        Thanks a bunch! It worked.
          A MODx Fanatic
          • 30585
          • 833 Posts
          Hi folks, it's time I asked for your help again.

          I'm still trying to search inside my custom database table with AdvSearch, but I still can't get it to work.

          I've renamed the package, updated and re-parsed the schema. I have no trouble retrieving the data from the table with Rowboat and my error log is clean.

          Here's the schema
          <?xml version="1.0" encoding="UTF-8"?>
          <model package="bible" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM" version="1.1">
          	<object class="bibleVerse" table="bible_verses" extends="xPDOSimpleObject">
          		<field key="book" dbtype="INT" precision="3" phptype="integer" null="false" default="0"/>
          		<field key="resource" dbtype="INT" precision="11" phptype="integer" null="false" default="0"/>
          		<field key="chapter" dbtype="INT" precision="3" phptype="integer" null="false" default="0"/>
          		<field key="verse" dbtype="INT" precision="3" phptype="integer" null="false" default="0"/>
          		<field key="translation" dbtype="enum" precision="'lsg','darby','ostervald','martin'" phptype="string" null="false" default="lsg" comment="Available Bible translations" />
          			
                  <aggregate alias="Resource" class="modResource" local="resource" foreign="id" cardinality="one" owner="foreign" />
                  <aggregate alias="Book" class="bibleBook" local="book" foreign="id" cardinality="one" owner="foreign" />        
          	</object>
          
          	<object class="bibleBook" table="bible_books" extends="xPDOSimpleObject">
          		<field key="book" dbtype="char" precision="60" phptype="string" null="false" default="" index="index"/>
          		<field key="chap" dbtype="INT" precision="3" phptype="integer" null="false" default="0"/>		
          	</object>	
          </model>


          I'm not worried about the bible_books table for now. All I want is a simple search inside the "bible_verses" table using a basic query hook, much like it's done here: http://www.revo.wangba.fr/custom-package-dvd-shop/ and here: http://forums.modx.com/thread/?thread=79145. It seems fairly simple to do, but I'm getting the generic results not found error when I do a search.

          I didn't specify a table prefix in the query snippet because I created my tables with MIGXdb, so the table prefix is "modx_". The full table names are "modx_bible_books" "modx_bible_verses".

          My query hook
          <?php
          $main = array(
              'package' => 'bible',
              'packagePath' => '{core_path}components/bible/model/',
              'class' => 'bibleVerse',    
              'fields' => 'id , book , chapter, lsg', // displayed
              'withFields' => 'book , chapter, lsg', // where we do the search    
              'sortby' => 'bibleVerse.id ASC'
          );
          
          
          // set the query hook declaration
          $qhDeclaration = array(
              'qhVersion' => '1.2',       // version of queryHook - to manage futures changes
              'main' => $main,
          );
          
          $hook->setQueryHook($qhDeclaration);
          
          return true;
          ?>

          My snippet calls:
          [[!AdvSearchForm? &addCss=`0` &addJQuery=`0` &tpl=`BibleSearchForm`]]
          [[!AdvSearch? &landing=`[[*id]]` &queryHook=`bibleQHook` &showExtract=`1:lsg`]]


          My BibleSearchForm tpl
          <form class="advsea-search-form" action="[[~[[+landing]]]]" method="[[+method]]">
            <fieldset>
              <input type="hidden" name="id" value="[[+landing]]" />
              <input type="hidden" name="asId" value="[[+asId]]" />
              [[+helpLink]]<input type="text" id="[[+asId]]_search" name="[[+searchIndex]]_2" value="[[+searchValue]]" />
              <input type="submit" name="sub" value="[[%advsearch.search? &namespace=`advsearch` &topic=`default`]]" />
            </fieldset>
          </form>
          [[+resultsWindow]]


          Am I doing something wrong?
            A MODx Fanatic
          • discuss.answer
            • 30585
            • 833 Posts
            For anyone having issues searching a custom table with AdvSearch , here's the fix that worked for me, courtesy of Alex (alexmercenary). I can't thank him enough for going out his way to lend a helping hand.

            The issue boils down to the 'tablePrefix' in the query Hook. I had recreated my package with CMPGenerator and I used the default tablePrefix: 'modx_'

            Here's my modified queryhook
            $main = array(
                'tablePrefix' => 'modx_', //The fix
                'package' => 'bible',
                'packagePath' => '{core_path}components/bible/model/',
                'class' => 'BibleVerse',  
                'fields' => 'id , book , verse, chapter, lsg', // displayed
            	'withFields' => 'book , verse, chapter, lsg', // Searched
            	'sortby' => 'BibleVerse.id ASC, BibleVerse.chapter ASC'
            );
            $andConditions = array(	
            	'BibleVerse.book:=' => 'book:request:all',
            	'BibleVerse.chapter:=' => 'chapter:request:all',
            	'BibleVerse.verse:=' => 'verse:request:all',
            	'BibleVerse.lsg:=' => 'lsg:request:all',
            );
            
            // set the query hook declaration
            $qhDeclaration = array(
                'qhVersion' => '1.2',       // version of queryHook - to manage futures changes
                'main' => $main,
                'andConditions' => $andConditions,	
            );
            
            $hook->setQueryHook($qhDeclaration);
            
            return true;


            My schema

            <?xml version="1.0" encoding="UTF-8"?>
            <model package="bible" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM" version="1.1">
            	<object class="BibleBook" table="bible_books" extends="xPDOSimpleObject">
            		<field key="book" dbtype="char" precision="60" phptype="string" null="false" default="" />
            		<field key="chap" dbtype="int" precision="3" phptype="integer" null="false" default="0" />
            		<composite alias="BibleVerse" class="BibleVerse" local="id" foreign="book" cardinality="many" owner="local" />
            	</object>
            	<object class="BibleVerse" table="bible_verses" extends="xPDOSimpleObject">
            		<field key="book" dbtype="int" precision="3" phptype="integer" null="false" default="0" />
            		<field key="resource" dbtype="int" precision="11" phptype="integer" null="false" default="0" />
            		<field key="chapter" dbtype="int" precision="3" phptype="integer" null="false" default="0" />
            		<field key="verse" dbtype="int" precision="3" phptype="integer" null="false" default="0" />
            		<field key="lsg" dbtype="text" phptype="string" null="false" />
            		<field key="darby" dbtype="text" phptype="string" null="false" />
            		<field key="ostervald" dbtype="text" phptype="string" null="false" />
            		<field key="martin" dbtype="text" phptype="string" null="false" />
            		<index alias="id" name="id" primary="false" unique="true" type="BTREE" >
            			<column key="id" length="" collation="A" null="false" />
            		</index>
            		<aggregate alias="BibleBook" class="BibleBook" local="book" foreign="id" cardinality="one" owner="foreign" />		
            		<aggregate alias="modResource" class="modResource" local="resource" foreign="id" cardinality="one" owner="foreign" />		
            	</object>
            </model>


            The snippet calls
            [[!AdvSearchForm? &addCss=`0` &addJQuery=`0` &tpl=`BibleSearchForm`]]
            [[!AdvSearch? &queryHook=`BibleQHook` &tpl=`BibleSearchResult` &highlightClass=`sisea-highlight`]]


            Once again, thanks to alexmercenary and I hope someone will find this helps.
              A MODx Fanatic
              • 49344
              • 6 Posts
              Hi treigh,

              can you describe me what placeholders you had passed in 'BibleSearchResult' tpl to display search result.
                • 30672
                • 180 Posts
                hi!

                Would also be interested in this answer smiley

                thanks !
                • Just the field's key?
                  [[+book]], etc
                    Rico
                    Genius is one percent inspiration and ninety-nine percent perspiration. Thomas A. Edison
                    MODx is great, but knowing how to use it well makes it perfect!

                    www.virtudraft.com

                    Security, security, security! | Indonesian MODx Forum | MODx Revo's cheatsheets | MODx Evo's cheatsheets

                    Author of Easy 2 Gallery 1.4.x, PHPTidy, spieFeed, FileDownload R, Upload To Users CMP, Inherit Template TV, LexRating, ExerPlan, Lingua, virtuNewsletter, Grid Class Key, SmartTag, prevNext

                    Maintainter/contributor of Babel

                    Because it's hard to follow all topics on the forum, PING ME ON TWITTER @_goldsky if you need my help.