Allows you to display an aggregated feed of posts originated from various social media sites.
This module allows you to display an aggregated feed of posts originated from various social media sites.
My intention was to make it easier to adapt the module to other frameworks. The core functionality is not relying on Silverstripe.
(You have to be logged in as administrator.)
composer require "devcreative/socialfeed"
edit the config file: Socialfeed.yaml
(Multiple feeds of the same type can be added.)
create a new SocialFeedPage.
//news source
class News extends DataObject {
private static $db = array(
,"Date" => "Date"
,"Title" => "Varchar(255)"
,"Content" => "HTMLText"
);
public function date() {
return $this->Date;
}
//...
}
class SocialFeedPage_Controller extends Page_Controller {
//...
public function getPosts() {
//get news and posts
$allNews = News::get();
$allPosts = $this->feeds->getAllPosts();
//merge into one array
foreach ($allNews as $news) {
array_push($allPosts, $news);
}
//sort by date
usort($allPosts, function($a, $b) {
return ($a->date() < $b->date())?true:false;
});
//create ArrayList for template
$list = ArrayList::create(array());
//add the sorted news and posts
foreach ($allPosts as $post) {
$list->push(
(get_class($post) == "News")?$post:ArrayData::create($post->data())
);
}
return new ArrayData(array("Posts" => $list));
}
//...
}
//templates may need to be modified to display news
Module rating system helping users find modules that are well supported. For more on how the rating system works visit Module standards
Score not correct? Let us know there is a problem