Automatically send a featured article to social media

  Previous article Next article  

Select a random CGBlog article and post it once a day to the social media using IFTTT.

  How to use

1. Create a new CGBlog summary template named "cgblog_featured_feed", using the following content:

{$current_date = $|date_format:'%d'}
{$stored_date = "{get_site_preference('featured_cgblog_stored_date','')}"}

{$featured_cgblog_id = "{get_site_preference('featured_cgblog_id','')}"}

{if $current_date != $stored_date}
  {foreach from=$items item=entry}
    {if $entry->id != $featured_cgblog_id}

{$featured_cgblog_description = "{get_site_preference('featured_cgblog_description','')}"}
{$featured_cgblog_id = "{get_site_preference('featured_cgblog_id','')}"}
{$featured_cgblog_title = "{get_site_preference('featured_cgblog_title','')}"}
{$featured_cgblog_url = "{get_site_preference('featured_cgblog_url','')}"}

{/strip}<rss version="2.0" xmlns:atom="">
<atom:link href="{root_url}/feed-featured.rss" rel="self" type="application/rss+xml" />
<description>Featured Article from {sitename}</description>
<generator>CMS Made Simple</generator>
+++ NOTE When stop using this feature, clean up the system by loading these lines once! +++

2. Create a new User Defined Tag named "content_type"

$content_type = get_parameter_value($params,'type');
if ($content_type != '') { cmsms()->set_content_type($content_type); }

3. Create in Design Manager a new Core::Page Template named "blank", that only contains:

{content wysiwyg=false}

4. Create a new content page "Feed Featured". In the options tab of the page editor you must use the new Core::Page template "blank" and set the page non-searchable, not in menu and WYSIWYG switched off!
In the page content you put:

{content_type type='application/rss+xml'}
{CGBlog summarytemplate='cgblog_featured_feed'}

Set in options tab Page URL: feed-featured.rss

You can test your feed at The random featured CGBlog article will be changed once a day at this RSS feed.

Attach this feed to and use it to post to Twitter or another social media platform of your choice.

5. More!
Because the featured article data is stored in a core site preference, we can also read it at other place at the website. Some examples:

{$featured_cgblog_description = "{get_site_preference('featured_cgblog_description','')}"}
<p>The featured CGBlog description is: {$featured_cgblog_description}</p>

{$featured_cgblog_id = "{get_site_preference('featured_cgblog_id','')}"}
<p>The featured CGBlog ID is: {$featured_cgblog_id}. You could use this like:</p>
{if $page_alias == 'home'}
  {$page_image = "{CGBlog action='detail' detailtemplate='cgblog_featured_detail' articleid=$featured_cgblog_id}"}

{$featured_cgblog_title = "{get_site_preference('featured_cgblog_title','')}"}
<p>The featured CGBlog title is: {$featured_cgblog_title}</p>

{$featured_cgblog_url = "{get_site_preference('featured_cgblog_url','')}"}
<p>The featured CGBlog URL is: {$featured_cgblog_url}</p>

I used this at the homepage of the CMS Made Simple Showcase

  Working example

Buy Me A Coffee

  Show related articles:

  Comment Form


Click here to open the form



No comments yet...

Buy Me A Coffee

CMS Made Simple - Tutorials, Tips and Tricks - CMSMS

Automatically send a featured article to social media

  Article optimized for CMSMS 2.x

  Last tested in: CMSMS 2.2.19
  Last updated: 23-07-2018
  Comments: 0

Buy Me A Coffee


Ads help me to help you! Thanks!

Ads help me to help you! Buy products from these advertisers!