<?xml version="1.0" encoding="UTF-8"?> <model package="bibleverses" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM" version="1.1"> <object class="bibleVerse" table="bible_verses" extends="xPDOSimpleObject"> <field key="book_id" dbtype="char" precision="3" phptype="integer" null="false" default="0"/> <field key="resource_id" dbtype="char" precision="11" phptype="integer" null="false" default="0"/> <field key="chapter" dbtype="mediumint" precision="3" phptype="integer" null="false" default="0"/> <field key="verse" dbtype="mediumint" precision="3" phptype="integer" null="false" default="0"/> <field key="lsg" dbtype="text" phptype="string" null="false" default="None"/> <field key="darby" dbtype="text" phptype="string" null="false" default="None"/> <field key="ostervald" dbtype="text" phptype="string" null="false" default="None"/> <field key="martin" dbtype="text" phptype="string" null="false" default="None"/> <index alias="PRIMARY" name="PRIMARY" primary="true" unique="true"> <column key="id" collation="A" null="false" /> </index> <field key="is_promesse" dbtype="int" precision="1" attributes="unsigned" phptype="integer" null="false" default="0"/> <aggregate alias="Resource" class="modResource" local="resource_id" foreign="id" cardinality="one" owner="foreign" /> <aggregate alias="Book" class="bibleBook" local="book_id" foreign="id" cardinality="one" owner="foreign" /> </object> </model>
/** * AdvSearch * * Copyright 2012 by Coroico <[email protected]> * * Query hook for the Dvd shop demo 1 * */ /* Main class: package - The name of the schema Package to add. e.g: dvd packagePath - The path to the model/ directory where the package is located. Use {core_path} as generic variable. class - The class name of the table you want to search. e.g: dvd and optionally (these parameters could be passed thru the snippet call): withFields - A comma-separated list of column names where to search. fields - A comma-separated list of column names to display. ids - A comma-separated list of primary keys to filter where the search should occurs. where - criteria or Array of criteria. e.g: "studio IN ('20th Century Fox','DreamWorks Home Ent.','Warner Bros') " sortby - csv list of couple 'columnName (ASC| DESC)'. */ $main = array( 'package' => 'bibleverses', 'packagePath' => '{core_path}components/bibleverses/model/', 'class' => 'bibleVerse', 'ids' => 'id', 'fields' => 'book_id , chapter , verse , lsg', // displayed 'withFields' => 'book_id , chapter , verse , lsg', // where we do the search 'joinCriteria' => 'modx_bible_books.id = modx_bible_verses.book_id', 'sortby' => 'modx_bible_verses.book_id ASC, modx_bible_verses.chapter ASC, modx_bible_verses.verse ASC', 'tablePrefix' => 'modx_' ); // set the query hook declaration $qhDeclaration = array( 'qhVersion' => '1.2', // version of queryHook - to manage futures changes 'main' => $main, ‘joined’ => $joined ); $hook->setQueryHook($qhDeclaration); return true;
[[!AdvSearchForm? &landing=`[[*id]]` &tpl=`AdvSearchForm`]] <h2>Results</h2> [[!AdvSearch? &queryHook=`bibleQHook` &tpl=`BibleSearchResult` &showExtract=`1:lsg`]]
This question has been answered by treigh. See the first response.
<aggregate alias="Book" class="bibleBook" local="book_id" foreign="id" cardinality="one" owner="foreign" />
<field key="lsg" dbtype="text" phptype="string" null="false" default="None"/> <field key="darby" dbtype="text" phptype="string" null="false" default="None"/> <field key="ostervald" dbtype="text" phptype="string" null="false" default="None"/> <field key="martin" dbtype="text" phptype="string" null="false" default="None"/>
<field key="translation" dbtype="enum" precision="'lsg','darby','ostervald','martin'" phptype="string" null="false" default="lsg" comment="The names of the versions which are allowed in the table" />
<index alias="PRIMARY" name="PRIMARY" primary="true" unique="true"> <column key="id" collation="A" null="false" /> </index>
<field key="is_promesse" dbtype="int" precision="1" attributes="unsigned" phptype="integer" null="false" default="0"/>
<field key="is_promesse" dbtype="tinyint" precision="1" attributes="unsigned" phptype="boolean" null="false" default="0" />
<?php $resourceObj = $modx->Resource; if ($resource instanceof modResource){ $parentObj = $modx->Resource->Parent; if ($parentObj instanceof modResource){ $bookObj = $modx->getObject('bibleBook', array('name' => $parentObj->get('pagetitle')); if ($bookObj instanceof bibleBook){ $collection = $bookObj->getMany('Verses', array('chapter' => $resourceObj->get('pagetitle', 'translation'=> 'darby'); if (count ($collection) > 0){ /* create output here */ } } }
Genesis 1 2
I would use MIGXdb, as a TV attached to a single document and using resources for everything (i.e. only accessing the site_content table). MODX can easily handle that many resources. Use one template for book, one for chapter, and one for verse. That way you can easily restrict searches and listings by filtering on template, and even parent's template.
http://rtfm.modx.com/extras/revo/migxdb/migxdb.tutorials/migxdb.manage-child-resources-in-a-grid-tv-with-help-of-migxdb