Version and environment: Running MODX 2.2.6-pl on Amazon's server.
Pretty embarrassed to admit it, but I've only actually built my own PHP snippets a few times in the last several years of using MODX (there I said it). As such, I have an some existing PHP snippet that's not in MODX that works great on my server on a static PHP page to grab info from an RSS feed. It's basically pulling in info from an RSS feed and I have no idea how to convert it into a MODX snippet and integrate into my MODX template. If you look at the code, it's pretty straightforward. The first part is just grabbing the function itself, pulling the values from the RSS feed and storing the variables in an array and then at the bottom we repeat the chunk of HTML 4 times plugging in the variables extracted from the RSS feed stored in the array and on the last of the 4 outputs, putting in a "last" class. I just need help converting this into a MODX snippet.
<?php
include('assets/rss-feed/function_getNewsData.php');
$articles = array();
$articles = getNewsBlock('http://www.website-url.net/admin/rss/fitness.rss', 4);
?>
<?php foreach ($articles as $article) { ?>
<div class="latest-news-post <?php if ($article === end($articles)) echo "last"; ?>">
<div class="img-arrow-hover">
<a href="<?php echo $article["link"]; ?>" class="latest-news-post-link"><img class="latest-news-post-img" src="<?php echo $article["image"]; ?>" alt="<?php echo $article["title"]; ?>" width="288" height="118"></a>
<img class="latest-news-post-arrow" src="assets/template/images/news/news-arrow.png" alt="news-arrow" width="288" height="10">
</div><!-- .img-arrow-hover -->
<img src="assets/template/images/news/news-arrow-shadow.png" alt="news-arrow-shadow" width="288" height="13">
<h4><a href="<?php echo $article["link"]; ?>"><?php echo $article["title"]; ?></a></h4>
<p><?php echo $article["content"]; ?></p>
</div><!-- .latest-news-post -->
<?php } ?>
Here was my attempt. I created a snippet named "getFeedDev".
include('assets/rss-feed/function_getNewsData.php');
$articles = array();
$articles = getNewsBlock('http://www.website-url.net/admin/rss/fitness.rss', 4);
$title = $article["title"];
$output = $modx->getChunk('rss-feed',array(
'title' => $title,
));
return $output;
Then I created this chunk named "rss-feed" to simply output the title but I get nothing: