Hi there,
I’m using a ditto call to list all my news items and show their appearance ranking tv values but I need to get an array which exists outside of the ditto call so I can then tell it to alter the sorting order by updating the ranking TV on the articles.
The ditto call is:
[!Ditto? &startID=`2,25` &summarize=`50` &sortBy=`ArticleRating` &sortDir=`DESC` &tpl=`Home_Page_Image_Rank_01` &debug=`1` !]
eg: snippet call in the chunk is :
[[rating_list? &pageid=`[+id+]`]]
and the rating_list snippet is this:
<?php
//$article_count=0;
global $modx;
global $sort_list;
global $article_count;
//$ditto_sort = int;
$gti_page_id= isset($pageid) ? $pageid : $modx->documentIdentifier;
$rating = "[+ArticleRating+]";
$page_id = $gti_page_id;
$rating= $modx->getTemplateVar('ArticleRating', "", $page_id);
echo"<br>ID:".$page_id." Rating:".$rating[value]."<br>";
/*
$ditto_sort_array = $modx->getPlaceholder('ditto_sort');
echo "<pre>***";
print_r($ditto_sort_array);
echo "***</pre>";
*/
//$previous_entry="[+rating_above+]";
$ditto_sort = "[+ditto_sort+]";
$sort_list[$ditto_sort][id]=$page_id;
$sort_list[$ditto_sort][rating]=$rating[value];
$modx->setPlaceholder('rating_number',"<br>PageID:".$ditto_sort."-".$sort_list[$ditto_sort][id]."-".$sort_list[$ditto_sort][rating]);
echo "<PRE>";
print_r($sort_list);
echo "END";
echo "</PRE>";
?>
I’m wanting to have the array in the form of:
Array
(
[0] => Array
(
[id] => 565
[rating] => 991170288001
)
[1] => Array
(
[id] => 452
[rating] => 991170288000
)
[2] => Array
(
[id] => 644
[rating] => 991170287999
}
To use in another php snippet which then looks up the array and makes the adjustments depending on which article link with the &moveup=644 (for eg) var being passed to it.
Where the array key id is the var from the ditto_sort placeholder.
The chunk only let’s the array exist in it’s one instance and it doesn’t let me use it outside of that chunk which is driving me slowly mad.
Any help/pointing out the clearly obvious most welcome!!
Many thanks
Jamie