Quote from: prioritypie at Jul 08, 2011, 07:29 AM
Thank you Bruno,
The problem I was having was that a "Resource List" TV type just outputs the ids, so I couldn't have the pagetitle included in the option string and I was trying to get it from within the (grid) rendering function. I've resorted to using a standard drop down list TV with a snippet to output the relevant resources in the pagetitle:id format as you suggested.
to complete this, the snippet-code for getResourceList:
<?php $parent=$modx->getOption('parent',$scriptProperties,'0'); $sortby=$modx->getOption('sortby',$scriptProperties,'pagetitle'); $c = $modx->newQuery('modResource'); $c->where(array('parent'=>$parent)); $c->sortby($sortby); $collection = $modx->getCollection('modResource',$c); $output='kein Partner==0'; foreach ($collection as $o){ $output .= '||'.$o->get('pagetitle').'=='.$o->get('pagetitle').':'.$o->get('id'); } return $output;
and then use this input-option-values:
@EVAL return $modx->runSnippet('getResourceList',array('parent'=>'3'));
Hey tomahl,
Sorry about the delay, I wasn't subscribed to this thread.
So if the the tag just outputs the url, then we have a problem... getImageList as I understand it is looking for a JSON array. Are you sure the input type of your TV is set to MIGX? What does your Form Tabs and Grid Columns contain? I'll subscribe to this so I can tell when you reply.
-Jared
[
{"caption":"Fil", "fields":[
{"field": "productDoc", "caption": "Fil", "inputTV": "productDocFile"},
{"field": "productDocTitle", "caption": "Titel"}
]}
][
{"header": "Fil", "width": "50", "sortable": "false", "dataIndex": "productDoc","renderer": "this.renderImage"},
{"header": "Titel", "width": "160", "sortable": "true", "dataIndex": "productDocTitle"}
]Sorry, but I get an error with the code of dzes. I'm using PHP5 and by calling the mergeMigx snippet I get this error
core/cache/includes/elements/modsnippet/53.include.cache.php : 324) PHP warning: implode() [<a href='function.implode'>function.implode</a>]: Invalid arguments passed
53 is the getImageList Snippet. If I use the original code of Bruno17 I get another error
includes/elements/modsnippet/57.include.cache.php 16) PHP warning: array_merge() [<a href='function.array-merge'>function.array-merge</a>]: Argument #1 is not an array
57 is the mergeMigx Snippet. But this error should be the one dzes also explained (array_merge() changes in PHP5).
mergeMigx call:
[[!mergeMigx? &tvname=`commercialRubric` &docid=`42` &tpl=`commercialRubricOutputInner` &where=`{"publishPage:=":"[[*id]]"}` &limit=`10` ]]
Edit: I'm using Migx 1.1.0 rc2
<?php
//[[mergeMIGX? &tvname=`mymigxtv` &docids=`10,11,12` &tpl=`mytpl` &debug=`1`]]
$docids = explode(',', $docids);
if ($tv = $modx->getObject('modTemplateVar', array('name' => $tvname))) {
$allitems = array();
foreach ($docids as $docid) {
$outputvalue = $tv->renderOutput($docid);
$items = $modx->fromJSON($outputvalue);
if (is_array($items)) {
$allitems = array_merge($allitems, $items);
}
elseif ($debug) {
echo 'Fehler in '.$docid.':'.$outputvalue;
}
}
$scriptProperties['value'] = $modx->toJSON($allitems);
}
return $modx->runSnippet('getImageList', $scriptProperties);
?>
what happens with this code:
<?php //[[mergeMIGX? &tvname=`mymigxtv` &docids=`10,11,12` &tpl=`mytpl` &debug=`1`]] $docids = explode(',', $docids); if ($tv = $modx->getObject('modTemplateVar', array('name' => $tvname))) { $allitems = array(); foreach ($docids as $docid) { $outputvalue = $tv->renderOutput($docid); $items = $modx->fromJSON($outputvalue); if (is_array($items)) { $allitems = array_merge($allitems, $items); } elseif ($debug) { echo 'Fehler in '.$docid.':'.$outputvalue; } } $scriptProperties['value'] = $modx->toJSON($allitems); } return $modx->runSnippet('getImageList', $scriptProperties); ?>
&docids=`41`
<?php return strftime($format);
&where=`{ "date:>" : "[[!strftime? &format=`%Y-%m-%d`]]" }`This discussion is closed to further replies. Keep calm and carry on.