Hi there!
Another problem I’ve ran into is the following:
I created a snippet to grab the photos off a flickr-album with the phpFlickr-wrapper. For doing so I created the following Flickr-snippet:
<?php
$album = $modx->getOption('setname',$scriptProperties,''); // get the flickr-album ID from the snippet-call
//include the core file
if(!class_exists("phpFlickr")) require_once './assets/phpflickr-master/phpFlickr.php';
if(!class_exists("PEAR")) require_once './assets/phpflickr/PEAR/PEAR.php';
// include the config file
require_once('./assets/phpflickr-master/config.php');
$f = new phpFlickr($key, $api_secret);
$f->enableCache("fs", "./assets/phpflickr-master/cache");
$mySetID = $album;
$mySet = $f->photosets_getPhotos($mySetID, NULL, NULL);
foreach ($mySet['photoset']['photo'] as $photo) {
$output .= '<div><a rel="lightbox[]" href="'. $f->buildPhotoURL($photo, 'large') .'"><img src="'. $f->buildPhotoURL($photo, 'medium') .'" alt="" /></a></div>';
}
return $output;
I’m using three different resources with a pagetitle and (right now for testing purposes I am using) the longtitle-input for the flickr-album-id:
[[Flickr? &setname=`[[+longtitle]]`]]
This results in something like that for example:
[[Flickr? &setname=`72157711365499999`]]
Then in my template I’m having a getResources call like this:
[[getResources? &parents=
[[*id]] &limit=
0 &sortdir=
asc &sortby=
menuindex &tpl=
galeries]]
The galeries-template looks like this:
<div class="gallery">
<a href="[[~[[+id]]]]">[[+pagetitle]]</a>
[[Flickr? &setname=`[[+longtitle]]`]]
</div>
When I run the snippet by loading the page which holds the getResources-call, the first album gets outputted.
But the second and third one do not appear at all. The error-log has the following entry:
[2019-12-13 16:59:21] (ERROR @ …/modx/core/cache/includes/elements/modsnippet/75.include.cache.php : 19) PHP warning: Invalid argument supplied for foreach()
So this error is related to the foreach-part. But why does this work the first time the snippet gets called, and not on any further calls?
I also tried to not use the getResources-call and to use 2 or 3 separate snippet-calls instead, but with the same issue (only getting the first album displayed). Additionally I tried to use the getResources-call and the Flickr-call cached and uncached, but no difference on that.
Any help on this is highly appreciated as well…and thank you for your time!