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:
https://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?