Page 1 of 1

[SOLVED] CGFeedMaker produces empty RSS feed from CGBlog

Posted: Fri Oct 23, 2015 10:48 pm
by postiffm
I have had for a long while a CGFeedMaker template for a blog rss feed. Apparently, about the end of August or early September 2015 it broke. The variable $items in the code below became empty. I added

Code: Select all

if (isset($items)) 
to fix the immediate problem of an undefined variable, but after that I am not clear how to fix the problem to get the blog entries into the $items array. I think it has something to do with global scope and a change to CGBlog that I discovered while researching the forums, but honestly I cannot figure out how to make it work. I have a very similar feed template for the News module and it works fine.

I think my main problem is that I still don't grok how templates and smarty work in CMS Made Simple. Sorry I'm a bit slow...

Code: Select all

    {CGBlog assign='junk' number=500}
    {foreach from=$items item='entry'}
    <item>
      <title>{$entry->title|cms_html_entity_decode}</title>
      <link>{$entry->moreurl}</link>
      {capture assign='description'}{if isset($entry->summary)}{$entry->summary}{else}{$entry->content}{/if}{/capture}
      <description>{$description|trim|strip_tags|unescape:"htmlall"}</description>
      <pubDate>{$entry->postdate|rfc_date}</pubDate>
      <guid>{$entry->moreurl}</guid>
    </item>
My setup:

CMS Install Information
CMS Version 1.12.1

Installed Modules
News 2.15.2
CSSMenu 1.2.2
TinyMCE 2.8.4
JSCookMenu .02
PHPLayers 1.1
FileManager 1.4.5
Printing 1.1.2
CMSMailer 5.2.2
MenuManager 1.8.7
CGSimpleSmarty 1.9.1
CGExtensions 1.49.7
CGBlog 1.13.1
CGFeedMaker 1.0.20
FrontEndUsers 1.30.4
Captcha 0.5.2
SelfRegistration 1.9.3
SiteMapMadeSimple 1.2.8
CMSPrinting 1.0.5
MicroTiny 1.2.9
ModuleManager 1.5.8
Search 1.7.13
ThemeManager 1.1.8
CMSForms 1.11.2
JQueryTools 1.3.7
VisitorStats 0.3.3
FormBuilder 0.8.1.1
CustomContent 1.10

Re: CGFeedMaker produces empty RSS feed from CGBlog

Posted: Sat Oct 24, 2015 9:26 am
by Rolf
I think this is related to Smarty Scope. assign="junk" doesnt work anymore... I will inform Calguy1000 of this.

Move this part to a new CGBlog Summary template, named i.e. cgfeedmaker:

Code: Select all

    {foreach from=$items item='entry'}
    <item>
      <title>{$entry->title|cms_html_entity_decode}</title>
      <link>{$entry->moreurl}</link>
      {capture assign='description'}{if isset($entry->summary)}{$entry->summary}{else}{$entry->content}{/if}{/capture}
      <description>{$description|trim|strip_tags|unescape:"htmlall"}</description>
      <pubDate>{$entry->postdate|rfc_date}</pubDate>
      <guid>{$entry->moreurl}</guid>
    </item>
And call in the CGFeedMaker template the module like:

Code: Select all

{CGBlog template='cgfeedmaker' number=500}
grtz. Rolf

Re: CGFeedMaker produces empty RSS feed from CGBlog

Posted: Sat Oct 24, 2015 7:32 pm
by postiffm
Thank you. This got me on the right track, but I'm not at the finish line yet.

Since CGBlog doesn't support template=, I had to change the suggested call to

Code: Select all

{CGBlog summarytemplate="cgfeedmaker" action="default" number=500}
Then, in the new CGBlog summary template, I had to change $entry->moreurl to $entry->url and add a prefix {root_url} to make a complete url to point to the entry. I don't understand why or how to debug it. For instance: what entry-> members are available to me now, and why is the list reduced from before?

Code: Select all

{foreach from=$items item='entry'}
    <item>
      <title>{$entry->title|cms_html_entity_decode}</title>
      <link>{root_url}/{$entry->url}</link>
      {capture name=PostDescription assign=desc}
          {if isset($entry->summary)}{$entry->summary}{else}{$entry->content}{/if}
      {/capture}
      <description>{$desc|trim|strip_tags|unescape:"htmlall"}</description>
      <pubDate>{$entry->postdate|rfc_date}</pubDate>
      <guid>{root_url}/{$entry->url}</guid>
    </item>
{/foreach}
Finally, I am stuck on the post description. The code that used to work is found below.

Code: Select all

      {capture assign='description'}{if isset($entry->summary)}{$entry->summary}{else}{$entry->content}{/if}{/capture}
      <description>{$description|trim|strip_tags|unescape:"htmlall"}</description>
But now this produces output
<description/>
which is very strange to me. I tried to change to the following, but it has the same problem.

Code: Select all

      {capture name=PostDescription assign=desc}
          {if isset($entry->summary)}{$entry->summary}{else}{$entry->content}{/if}
      {/capture}
      <description>{$desc|trim|strip_tags|unescape:"htmlall"}</description>

Re: CGFeedMaker produces empty RSS feed from CGBlog

Posted: Sat Oct 24, 2015 11:42 pm
by postiffm
If instead I split the <description> code into three lines like this

Code: Select all

<description>
{$desc|trim|strip_tags|unescape:"htmlall"}
</description>
then I get
<description></description>
(By the way, I am planning to move to 2.0.1 soon, but I want to make sure I start with a working site before making that big change. Thanks to the dev team and all for working on this software, as it has been very helpful to me over the years.)

Re: CGFeedMaker produces empty RSS feed from CGBlog

Posted: Sun Oct 25, 2015 7:43 am
by Rolf

Re: CGFeedMaker produces empty RSS feed from CGBlog

Posted: Sun Oct 25, 2015 9:17 pm
by postiffm
Thanks Rolf. Your code helped me revise my feed "summary template" in CGBlog. I still use CGFeedMaker so I don't follow all the instructions in your post, but it was just what the doctor ordered. I'm at the finish line now.

Code: Select all

{foreach from=$items item=entry}
    <item>
      <title>{$entry->title|escape}</title>
      <link>{$entry->detail_url}</link>
      <description>{strip}
          {if $entry->summary}
              {eval var=$entry->summary|escape}
          {else}
              {eval var=$entry->content|escape}
          {/if}
      {/strip}</description>
      <pubDate>{$entry->postdate|rfc_date}</pubDate>
      <guid>{$entry->detail_url}</guid>
    </item>
{/foreach}