I am trying to do a social media aggregator at my site, where it will grab the feed from Facebook and Instagram and display it in home page,
I got it working using the core aggregator module in Drupal 8, But Its not displaying the images on Facebook and Instagram, while for Instagram its only displaying title. This (I think) is due to the different structure of XML files from feed generator.
So, I started to trace the code and ended up finding that aggregatorFeedBlock is where I need to change some lines such as:
‘#title’ => $ item->label(),
To:
‘#title’ => $ item->getdescription(),
This is the full method:
public function build() { // Load the selected feed. if ($ feed = $ this->feedStorage->load($ this->configuration['feed'])) { $ result = $ this->itemStorage->getQuery() ->condition('fid', $ feed->id()) ->range(0, $ this->configuration['block_count']) ->sort('timestamp', 'DESC') ->sort('iid', 'DESC') ->execute(); if ($ result) { // Only display the block if there are items to show. $ items = $ this->itemStorage->loadMultiple($ result); $ build['list'] = [ '#theme' => 'item_list', '#items' => [], ]; foreach ($ items as $ item) { $ build['list']['#items'][$ item->id()] = [ '#type' => 'link', '#url' => $ item->urlInfo(), '#title' => $ item->label(), ]; } $ build['more_link'] = [ '#type' => 'more_link', '#url' => $ feed->urlInfo(), '#attributes' => ['title' => $ this->t("View this feed's recent news.")], ]; return $ build; } } }
So, How can I change this without changing the code in core folder? Can I create a custom module that overwrites this method? Can I change have 2 different methods one for Facebook and another one for Instagram ??