Hi Guys,
I have a snippet I want to loop with an array of document Ids. I want to specify...say 100 Doc id’s manually and have the snippet loop through all of those documents.
This first snippet gets a value from a CSV parser and puts the value in a Template variable. I want to loop this snippet across 100 documents. This snippet is working.
<?php
$vidId = isset($vidId)? $vidId : '';
$output = $modx->runSnippet('updateViews',array(
'url' => 'http://domain.com/'.$vidId.'.flv'
));
$tv = $modx->getObject('modTemplateVar',array('name'=>'vidViewCount'));
$tv->setValue($vidId, $output);
$tv->save();
I was trying to make this second snippet the loop but this is where it is failing.
<?php
$arr = array(13, 14, 15);
foreach ($arr as $arrItem) {
$modx->runSnippet('executeViewsUpdate',array(
'vidId' => '$arrItem'));
}
I intend to execute this second snippet via cronmanager every 24 hours to update a list of view counts.
Any guidance on how to achieve this appreciated.
Best Regards,
Stuart