Thanks for sharing your working code, I'm sure people will thank you in the future
] <?xml version="1.0" encoding="UTF-8"?>
<model package="my_music" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM" version="1.1">
<object class="TblArtist" table="tbl_artist" extends="xPDOObject">
<field key="artist_id" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="false" index="pk" generated="native" />
<field key="name" dbtype="varchar" precision="100" phptype="string" null="false" default="" />
<field key="bio" dbtype="text" phptype="string" null="false" />
<index alias="PRIMARY" name="PRIMARY" primary="true" unique="true" type="BTREE" >
<column key="artist_id" length="" collation="A" null="false" />
</index>
</object>
<object class="TblCd" table="tbl_cd" extends="xPDOObject">
<field key="cd_id" dbtype="int" precision="10" phptype="integer" null="false" index="pk" generated="native" />
<field key="cd_title" dbtype="varchar" precision="255" phptype="string" null="true" />
<field key="cd_info" dbtype="text" phptype="string" null="false" />
<field key="cd_image" dbtype="varchar" precision="255" phptype="string" null="true" />
<field key="cd_thumbImage" dbtype="varchar" precision="50" phptype="string" null="true" />
<field key="cd_images1" dbtype="varchar" precision="30" phptype="string" null="true" />
<field key="cd_images1txt" dbtype="varchar" precision="30" phptype="string" null="true" />
<field key="cd_images2" dbtype="varchar" precision="30" phptype="string" null="true" />
<field key="cd_images2txt" dbtype="varchar" precision="30" phptype="string" null="true" />
<field key="cd_images3" dbtype="varchar" precision="30" phptype="string" null="true" />
<field key="cd_images3txt" dbtype="varchar" precision="30" phptype="string" null="true" />
<field key="cd_images4" dbtype="varchar" precision="30" phptype="string" null="true" />
<field key="cd_images4txt" dbtype="varchar" precision="30" phptype="string" null="true" />
<field key="cd_images5" dbtype="varchar" precision="30" phptype="string" null="true" />
<field key="cd_images5txt" dbtype="varchar" precision="30" phptype="string" null="true" />
<field key="cd_images6" dbtype="varchar" precision="30" phptype="string" null="true" />
<field key="cd_images6txt" dbtype="varchar" precision="30" phptype="string" null="true" />
<field key="cd_images7" dbtype="varchar" precision="30" phptype="string" null="true" />
<field key="cd_images7txt" dbtype="varchar" precision="30" phptype="string" null="true" />
<field key="cd_artist" dbtype="varchar" precision="50" phptype="string" null="true" default="John Hunter" />
<field key="metaKeywords" dbtype="varchar" precision="255" phptype="string" null="true" default="John Hunter, CDs, Music, 404, Songs" />
<field key="cd_purchase" dbtype="varchar" precision="20" phptype="string" null="false" default="" />
<index alias="PRIMARY" name="PRIMARY" primary="true" unique="true" type="BTREE" >
<column key="cd_id" length="" collation="A" null="false" />
</index>
<composite alias="TblCd" class="TblCd" local="cd_id" foreign="cd_idTitle" cardinality="many" owner="local" />
<composite alias="TblCd" class="TblCd" local="cd_id" foreign="cd_idImage" cardinality="many" owner="local" />
</object>
<object class="TblCdcontent" table="tbl_cdcontent" extends="xPDOObject">
<field key="cdTrack_id" dbtype="int" precision="10" phptype="integer" null="false" index="pk" generated="native" />
<field key="cd_idTitle" dbtype="int" precision="10" phptype="integer" null="true" />
<field key="cd_idSong" dbtype="int" precision="10" phptype="integer" null="true" />
<field key="cd_trackNumber" dbtype="int" precision="10" phptype="integer" null="true" />
<index alias="PRIMARY" name="PRIMARY" primary="true" unique="true" type="BTREE" >
<column key="cdTrack_id" length="" collation="A" null="false" />
</index>
<aggregate alias="TblCdcontent" class="TblCdcontent" local="cd_idSong" foreign="song_id" cardinality="one" owner="foreign" />
<aggregate alias="TblCdcontent" class="TblCdcontent" local="cd_idTitle" foreign="cd_title" cardinality="one" owner="foreign" />
</object>
<object class="TblRecordings" table="tbl_recordings" extends="xPDOObject">
<field key="recording_id" dbtype="int" precision="10" phptype="integer" null="false" index="pk" generated="native" />
<field key="recordingTitle" dbtype="varchar" precision="255" phptype="string" null="true" />
<field key="version" dbtype="varchar" precision="255" phptype="string" null="true" />
<field key="recording_idSong" dbtype="int" precision="10" phptype="integer" null="true" />
<field key="recording_length" dbtype="time" phptype="string" null="true" />
<field key="year_recorded" dbtype="year" precision="4" phptype="string" null="true" />
<field key="source" dbtype="varchar" precision="255" phptype="string" null="true" />
<field key="original" dbtype="varchar" precision="255" phptype="string" null="true" />
<field key="notes" dbtype="varchar" precision="255" phptype="string" null="true" />
<field key="equipment" dbtype="text" phptype="string" null="true" />
<field key="customerRating" dbtype="float" phptype="float" null="false" default="0" />
<field key="description" dbtype="text" phptype="string" null="false" />
<field key="brief_description" dbtype="text" phptype="string" null="false" />
<field key="category_id" dbtype="int" precision="11" phptype="integer" null="true" default="2" />
<field key="big_picture" dbtype="varchar" precision="30" phptype="string" null="true" />
<field key="picture" dbtype="varchar" precision="30" phptype="string" null="true" />
<field key="image_title" dbtype="varchar" precision="255" phptype="string" null="true" />
<field key="thumbnail" dbtype="varchar" precision="30" phptype="string" null="true" />
<field key="enabled" dbtype="int" precision="11" phptype="integer" null="false" default="0" />
<field key="recording_mp3" dbtype="varchar" precision="50" phptype="string" null="true" />
<field key="recording_download" dbtype="varchar" precision="50" phptype="string" null="true" />
<field key="date_uploaded" dbtype="timestamp" phptype="timestamp" null="false" default="CURRENT_TIMESTAMP" />
<field key="artist" dbtype="varchar" precision="20" phptype="string" null="false" default="John Hunter" />
<index alias="PRIMARY" name="PRIMARY" primary="true" unique="true" type="BTREE" >
<column key="recording_id" length="" collation="A" null="false" />
</index>
<aggregate alias="TblRecordings" class="TblRecordings" local="recording_id" foreign="recording_idSong" cardinality="one" owner="foreign" />
</object>
<object class="TblSongs" table="tbl_songs" extends="xPDOObject">
<field key="song_id" dbtype="int" precision="10" phptype="integer" null="false" index="pk" generated="native" />
<field key="song_title" dbtype="varchar" precision="255" phptype="string" null="true" index="index" />
<field key="song_writer" dbtype="varchar" precision="60" phptype="string" null="true" default="Words & Music John Hunter" />
<field key="song_year" dbtype="int" precision="10" phptype="integer" null="true" />
<field key="song_date" dbtype="date" phptype="date" null="true" index="index" />
<field key="song_lyrics" dbtype="text" phptype="string" null="true" />
<field key="song_number" dbtype="int" precision="10" phptype="integer" null="true" />
<field key="backgroundStory" dbtype="text" phptype="string" null="true" />
<field key="songKeywords" dbtype="varchar" precision="255" phptype="string" null="true" />
<index alias="PRIMARY" name="PRIMARY" primary="true" unique="true" type="BTREE" >
<column key="song_id" length="" collation="A" null="false" />
</index>
<index alias="Date" name="Date" primary="false" unique="false" type="BTREE" >
<column key="song_date" length="" collation="A" null="true" />
</index>
<index alias="Song Title" name="Song Title" primary="false" unique="false" type="BTREE" >
<column key="song_title" length="" collation="A" null="true" />
</index>
<index alias="song_id" name="song_id" primary="false" unique="false" type="BTREE" >
<column key="song_id" length="" collation="A" null="false" />
</index>
<composite alias="TblRecordings" class="TblRecordings" local="song_id" foreign="recording_idSong" cardinality="many" owner="local" />
<composite alias="TblRecordings" class="TblRecordings" local="song_id" foreign="cd_idSong" cardinality="many" owner="local" />
</object>
</model><?php
/**
* my_music
*/
$output = '';// this is what the snippet will return
// add package so xpdo can be used:
$package_path = $modx->getOption('core_path').'components/my_music/model/';
// see the scheme file and the xml model element and you will see the attribute package and that must match here
$modx->addPackage('my_music', $package_path);
// lets add some data!
// see the scheme file and the xml object element and you will see the attribute class and that must match here
// now lets show the data in a quick and dirty table:
$output .= '
<table>
<tr>
<th>song_id</th>
<th>song_title</th>
<th>song_date</th>
</tr>';
// Note for all HTML you should be using Chunks see: http://rtfm.modx.com/display/revolution20/Chunks#Chunks-ProcessingChunkviatheAPI
/* build query */
$query = $modx->newQuery('my_music');
$rows = $modx->getIterator('my_music, $query);
/* iterate */
$list = array();
foreach ($rows as $row) {
// from object to array you can also do $row->get('song_title');
$row_array = $row->toArray();
$output .= '
<tr>
<td>'.$row_array['song_id'].'</td>
<td>'.$row_array['song_title'].'</td>
<td>'.$row_array['song_date'].'</td>
</tr>';
}
$output .= '
</table>';
return $output;yes the snippet is called my_music and I checked the source code of the home page which I put the[[!my_music]] in and that looks fine too. Very confused
Quote from: johnrlhunter at Jan 31, 2013, 02:15 PMyes the snippet is called my_music and I checked the source code of the home page which I put the[[!my_music]] in and that looks fine too. Very confused
if you PM me the url and credentials I can take a [quick] look, but it still sounds to me like modx is not processing the tag for some reason.