[Solved] CGFeedMaker Issue with News Module

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Locked
ColonelBlimp
Forum Members
Forum Members
Posts: 12
Joined: Fri Nov 06, 2015 5:06 am

[Solved] CGFeedMaker Issue with News Module

Post by ColonelBlimp »

Using: cmsms 2.1, php 5.5.12, apache 2.4.9, CGExtensions 1.50, CGFeedMaker 1.0.20

Defaults:
1. News feed template (except the <atom .. /> line is commented out for now as pretty_urls are not currently enabled).
2. Default 'News Summary Sample' template (which is the default for summary news).

The Issue:
I can access the feed, but no news gets onto the feed. I've tried adding new news items; changing the post date; switching on/off expiry... nothing seems enable me to get a news item summary into the feed.
Hard coding the template works fine. So, it seems that the following line from the template is not able to access news items:

Code: Select all

{News assign='junk' detailpage=$feed.pageid}
as nothing inside the:

Code: Select all

{if isset($items)}
...
{/if}
is executed.
Can anyone point me in the direction of what I am doing wrong?

Many thanks.
Last edited by ColonelBlimp on Tue Dec 15, 2015 4:36 am, edited 1 time in total.
ColonelBlimp
Forum Members
Forum Members
Posts: 12
Joined: Fri Nov 06, 2015 5:06 am

Re: CGFeedMaker Issue with News Module

Post by ColonelBlimp »

Results of further testing:

Test 1:

Code: Select all

{News assign='junk'}
Still no joy...
Test 2:

Code: Select all

{News}
Now the 'default' news summary template is rendered in the xml feed file. It seems that variables from the News Module are not being propagated to the feed template?

I'm not sure if this is a bug or something I'm doing wrong. I've tried this out on two separate installs of cmsms 2.1 - same results. I have not tested previous versions of cmsms.

My fall-back position seems to be to create a News::Summary template with the appropriate rss markup?
User avatar
Rolf
Power Poster
Power Poster
Posts: 7825
Joined: Wed Apr 23, 2008 7:53 am
Contact:

Re: CGFeedMaker Issue with News Module

Post by Rolf »

It doesnt work because of Smarty scope.
Create summary template like described here http://www.cmscanbesimple.org/blog/crea ... t-a-module and call it in CGFeedmaker template
- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
Image
ColonelBlimp
Forum Members
Forum Members
Posts: 12
Joined: Fri Nov 06, 2015 5:06 am

Re: CGFeedMaker Issue with News Module

Post by ColonelBlimp »

Thank you for replying so quickly.
Rolf wrote:Create summary template like described here http://www.cmscanbesimple.org/blog/crea ... t-a-module and call it in CGFeedmaker template
This is what I have done (my fall-back position) and it works just fine - indeed, it seems more logical to have the RSS template listed along with all the other templates.
Rolf wrote:It doesnt work because of Smarty scope.
The documentation states that it should work... so is this a bug that should be reported?

Thanks again.
ColonelBlimp
Forum Members
Forum Members
Posts: 12
Joined: Fri Nov 06, 2015 5:06 am

Re: CGFeedMaker Issue with News Module

Post by ColonelBlimp »

A Working Solution:

Create a Design template of the type News::Summary as follows:

Code: Select all

{if isset($items)}
{foreach $items as $entry}
<item>
  <title>{$entry->title|cms_html_entity_decode}</title>
{capture assign='description'}{if isset($entry->summary)}{$entry->summary}{else}{$entry->content}{/if}{/capture}
  <description>{$description|trim|strip_tags|summarize:80}</description>
  <pubDate>{$entry->postdate|rfc_date}</pubDate>
  <guid>{$entry->moreurl}</guid>
</item>
{/foreach}
{/if}
Modify the news template in CGFeedMaker as follows:

Code: Select all

{* original rss feed template *}
<?xml version="1.0"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
  {* note: if you have not configured pretty urls or mod rewrite, the next line may fail when trying to validate the feed *}
  <atom:link href="{$feed_url}" rel="self" type="application/rss+xml" />
    <title>{$feed.title|cms_escape}</title>
    {if isset($feed.link) && !empty($feed.link)}<link>{$feed.link}</link>{/if}
    {if isset($feed.description) && !empty($feed.description)}<description>{$feed.description}</description>{/if}
    {if isset($feed.copyright) && !empty($feed.copyright)}<copyright>{$feed.copyright}</copyright>{/if}
    {if isset($generator)}<generator>{$generator}</generator>{/if}
    {if isset($feed.managing_editor) && !empty($feed.managing_editor)}<managingEditor>{$feed.managing_editor}</managingEditor>{/if}
    {if isset($admin_email)}<webMaster>{$admin_email} ({$admin_user->firstname} {$admin_user->lastname})</webMaster>{/if}
    {if isset($feed.image) && !empty($feed.image)}
      <image>
	{if isset($feed.description) && !empty($feed.description)}<description>{$feed.description}</description>{/if}
        {if isset($feed.link) && !empty($feed.link)}<link>{$feed.link}</link>{/if}
        <title>{$feed.title}</title>
        <url>{$file_location}/{$feed.image}</url>
      </image>
    {/if}

    {* an example of how to create a feed from a call to the news module *}
    {* you can use any smarty variable that is available in the news summary template *}
    {* you can substitute this logic with output from any module that supports a summary
       view, or possibly get artistic and mix output from different modules *}
    {News summarytemplate='your_template_name'}
  </channel>
</rss>
And you should be good to go.
DON'T FORGET: you will need pretty_urls enabled for the <atom:link .../> to work!
Locked

Return to “Modules/Add-Ons”