0
votes

I have created similar table to this one http://rtfm.modx.com/display/ADDON/MIGX.Simple+opening+hours+table

I have successfully exported data to resource, but i want to show it in a chunk so i can display it in getresources.

I use getresources to display resources and besides title and intro text i would like to show datesTV data.

I use template chunk for migx:

 [[+date:notempty=`<td>[[+date:strtotime:date=`%d.%m.%Y, %H.%M`]]</td>`:default=`<td colspan="2">No show!</td>`]]

If i use this in other chunk for getresources [[+tv.datesTV]] i get this array out:

 [{"MIGX_id":"1","date":"2012-10-28 21:00:00"},{"MIGX_id":"2","date":"2012-10-28 01:45:00"},{"MIGX_id":"3","date":"2012-10-30 02:45:00"}]

How can I display this data as it should be in a chunk.

2

2 Answers

1
votes

Ok here you can se how my snippet looks like..

<?php
$strJSON = $modx->resource->getTVValue('spored');
$arrJSON = $modx->fromJSON($strJSON);

foreach($arrJSON as $arrJSONDataSet)
{
  foreach($arrJSONDataSet as $key => $value)
 {
    echo $key . ' => ';
    echo $value;
    echo '<br />';
  }
}
0
votes

With MIGX you need a snippet to parse and format the raw TV data as it's stored as JSON.

For a rough example of how to do this, refer back to the link you mentioned and try the getImageList snippet: http://rtfm.modx.com/display/ADDON/MIGX.Simple+opening+hours+table#MIGX.Simpleopeninghourstable-ParsingtheData

You'll need to include that snippet call in your getResources chunk which is going to be really inefficient; it would be better to code up a custom snippet to retrieve the necessary data.

But see how that goes first...