We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

FIXED! (Thx Robin!) RSS feed from 2.1.4 no longer works with conditionals in 3.2.0

How Do I?

tbritton's avatar
tbritton
714 posts
9 years ago
tbritton's avatar tbritton

We just upgraded to 3.2.0 from 2.1.4, and the move seems to have broken my RSS feeds completely. I used several conditionals to assign the correct paths to each template group section, but none of those seem to work now. See the following for a representative example – perhaps you can divulge what I need to change for parsing to work in the new EE. (You’re seeing part of code that has worked for eight years until we updated.)

{preload_replace:master_channel_name="restaurants|arts|community|kids|blogs|rural_road_trips|style|food|parties"}
{exp:rss:feed channel="{master_channel_name}"}
<?xml version="1.0" encoding="{encoding}"?>
<rss version="2.0"
    xmlns:atom="http://www.w3.org/2005/Atom"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
    xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
    xmlns:admin="http://webns.net/mvcb/"
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:content="http://purl.org/rss/1.0/modules/content/">
    <channel>
   <title>{exp:xml_encode}Rural Intelligence{/exp:xml_encode}</title>
    <link>{channel_url}</link>
    <atom:link href="{path=feed/RSS_2.0}" rel="self" type="application/rss+xml" >
    <description>Your guide to Rural Living</description>
    <dc:language>{channel_language}</dc:language>
    <dc:creator>{email}</dc:creator>
    <dc:rights>Copyright {gmt_date format="%Y"}</dc:rights>
    <dc:date>{gmt_date format="%Y-%m-%dT%H:%i:%s%Q"}</dc:date>
    <admin:generatorAgent rdf:resource="http://expressionengine.com/" >
{exp:channel:entries channel="{master_channel_name}" limit="19" rdf="off" dynamic_start="on" status="open" disable="member_data|trackbacks" category_group="1|2|3|4|5|6|7|8|13|14|15"}
    <item>
{if channel_id=="24"}
      <title>{exp:xml_encode}{title} -- Restaurants -- {categories}{category_name}{/categories} {/exp:xml_encode}</title>
      <link>{title_permalink=food_section/food_restaurant_listing}</link>
      <guid>{title_permalink=food_section/food_restaurant_listing}</guid>
      <description>{exp:xml_encode}{article}{/exp:xml_encode}</description>
      <dc:subject>{exp:xml_encode}{categories backspace="1"}{category_name}, {/categories}{/exp:xml_encode}</dc:subject>
      <dc:date>{gmt_entry_date format="%Y-%m-%dT%H:%i:%s%Q"}</dc:date>
{/if}
{categories}
{if channel_id=="12" AND category_id=="16"}
{/categories}
      <title>{exp:xml_encode}{title} -- Arts Section -- {categories}{category_name}{/categories} {/exp:xml_encode}</title>
      <link>{title_permalink=arts_section/arts_articles_movies}</link>
      <guid>{title_permalink=arts_section/arts_articles_movies}</guid>
      <description>{exp:xml_encode}{article}{/exp:xml_encode}</description>
      <dc:subject>{exp:xml_encode}{categories backspace="1"}{category_name}, {/categories}{/exp:xml_encode}</dc:subject>
      <dc:date>{gmt_entry_date format="%Y-%m-%dT%H:%i:%s%Q"}</dc:date>
{/if}
{categories}
{if channel_id=="12" AND category_id=="17"}
{/categories}
      <title>{exp:xml_encode}{title} -- Arts Section -- {categories}{category_name}{/categories} {/exp:xml_encode}</title>
      <link>{title_permalink=arts_section/arts_articles_music}</link>
      <guid>{title_permalink=arts_section/arts_articles_music}</guid>
      <description>{exp:xml_encode}{article}{/exp:xml_encode}</description>
      <dc:subject>{exp:xml_encode}{categories backspace="1"}{category_name}, {/categories}{/exp:xml_encode}</dc:subject>
      <dc:date>{gmt_entry_date format="%Y-%m-%dT%H:%i:%s%Q"}</dc:date>
{/if}
{categories}
{if channel_id=="12" AND category_id=="18"}
{/categories}
      <title>{exp:xml_encode}{title} -- Arts Section -- {categories}{category_name}{/categories} {/exp:xml_encode}</title>
      <link>{title_permalink=arts_section/arts_articles_art}</link>
      <guid>{title_permalink=arts_section/arts_articles_art}</guid>
      <description>{exp:xml_encode}{article}{/exp:xml_encode}</description>
      <dc:subject>{exp:xml_encode}{categories backspace="1"}{category_name}, {/categories}{/exp:xml_encode}</dc:subject>
      <dc:date>{gmt_entry_date format="%Y-%m-%dT%H:%i:%s%Q"}</dc:date>
{/if}
{categories}
{if channel_id=="12" AND category_id=="19"}
{/categories}
      <title>{exp:xml_encode}{title} -- Arts Section -- {categories}{category_name}{/categories} {/exp:xml_encode}</title>
      <link>{title_permalink=arts_section/arts_articles_theater}</link>
      <guid>{title_permalink=arts_section/arts_articles_theater}</guid>
      <description>{exp:xml_encode}{article}{/exp:xml_encode}</description>
      <dc:subject>{exp:xml_encode}{categories backspace="1"}{category_name}, {/categories}{/exp:xml_encode}</dc:subject>
      <dc:date>{gmt_entry_date format="%Y-%m-%dT%H:%i:%s%Q"}</dc:date>
{/if}
{categories}
{if channel_id=="12" AND category_id=="20"}
{/categories}
      <title>{exp:xml_encode}{title} -- Arts Section -- {categories}{category_name}{/categories} {/exp:xml_encode}</title>
      <link>{title_permalink=arts_section/arts_articles_books}</link>
      <guid>{title_permalink=arts_section/arts_articles_books}</guid>
      <description>{exp:xml_encode}{article}{/exp:xml_encode}</description>
      <dc:subject>{exp:xml_encode}{categories backspace="1"}{category_name}, {/categories}{/exp:xml_encode}</dc:subject>
      <dc:date>{gmt_entry_date format="%Y-%m-%dT%H:%i:%s%Q"}</dc:date>
{/if}
    </item>
{/exp:channel:entries}
    </channel>
</rss>
{/exp:rss:feed}

You get the idea… What is going wrong in 3.2.0?

Thanks!

Terry

       
tbritton's avatar
tbritton
714 posts
9 years ago
tbritton's avatar tbritton

BTW -

I did replace {exp:xml_encode} and {/exp:xml_encode} with <![CDATA[ and ]]> but that changed nothing. The main problems now are with the conditionals breaking.

Likely {exp:xml_encode} was a plugin or add-on that worked for years until now. I don’t remember the details at the moment.

Terry

       
tbritton's avatar
tbritton
714 posts
9 years ago
tbritton's avatar tbritton

One sec - did the .(JavaScript must be enabled to view this email address) replace the categories tag within/between exp:channel:entries tags?

If so, that would explain a lot.

Terry

       
tbritton's avatar
tbritton
714 posts
9 years ago
tbritton's avatar tbritton

No matter what I try, I cannot find ANY parsing order that works. I’m beyond frustrated, having made it to dismayed.

Please help!!

Terry

       
Hop Studios's avatar
Hop Studios
459 posts
9 years ago
Hop Studios's avatar Hop Studios

That code would be problematic in any version of EE. You shouldn’t have part of an IF statement inside a categories tag, and the other half outside of it. That could be the issue right there.

TTFN Travis

       
tbritton's avatar
tbritton
714 posts
9 years ago
tbritton's avatar tbritton
That code would be problematic in any version of EE. You shouldn’t have part of an IF statement inside a categories tag, and the other half outside of it. That could be the issue right there. TTFN Travis

When I originally coded this, that order of things was the only one that would work.

No sequence works at the moment. However, you are entirely correct that what you suggest is the properly formatted approach that should work, so I will stick to that syntax you mention for the rest of my tests.

I’m going to try what is suggested here:

http://expressionengine.stackexchange.com/questions/31184/creating-a-multi-channel-rss-feed

Terry

       
tbritton's avatar
tbritton
714 posts
9 years ago
tbritton's avatar tbritton

No luck there.

The problem is that I used categories for sections within each channel, and need to sift for those.

But the “AND” logic is not working with either the {categories} tag nor the {exp:channel:categories} tag.

I’m only working with a single segment trying to get it to work, but keep getting errors.

{categories}
{if channel_id=="12" AND category_id=="20"}

      <title>{exp:xml_encode}{title} -- Arts Section -- {categories}{category_name}{/categories} {/exp:xml_encode}</title>
      <link>{title_permalink=arts_section/arts_articles_books}</link>
      <guid>{title_permalink=arts_section/arts_articles_books}</guid>
      <description>{exp:xml_encode}{article}{/exp:xml_encode}</description>
      <dc:subject>{exp:xml_encode}{categories backspace="1"}{category_name}, {/categories}{/exp:xml_encode}</dc:subject>
      <dc:date>{gmt_entry_date format="%Y-%m-%dT%H:%i:%s%Q"}</dc:date>
{/if}
{/categories}

I cannot fathom any reason why the above should not be working.

Terry

       
Robin Sowell's avatar
Robin Sowell
13,159 posts
9 years ago
Robin Sowell's avatar Robin Sowell

I’m spotting one thing that will definitely cause a problem- it’s the nested {category} tags. Do you have your debug turned on- in Settings- ‘Debugging and Output’.

If I try your simplified example, I’m getting

Error You have an invalid conditional in your template. Please review your conditionals for an unclosed string, invalid operators, a missing }, or a missing {/if}. Parser State: Unexpected end of Template “site/feed” on line 3; expected ENDIF tag for opening on line 1.

If I remove the nested category tags, it works. v3 (and v2.10) use an updated conditional parser that’s is more stringent in its requirements with regard to allowing stray conditionals.

If I take out the nested, it’s parsing for me- here’s the simplified version I tested with:

{exp:rss:feed channel="about"}
<?xml version="1.0" encoding="{encoding}"?>
<rss version="2.0"
    xmlns:atom="http://www.w3.org/2005/Atom"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
    xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
    xmlns:admin="http://webns.net/mvcb/"
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:content="http://purl.org/rss/1.0/modules/content/">
    <channel>
   <title>{exp:xml_encode}Rural Intelligence{/exp:xml_encode}</title>
    <link>{channel_url}</link>
    <atom:link href="{path=feed/RSS_2.0}" rel="self" type="application/rss+xml" >
    <description>Your guide to Rural Living</description>
    <dc:language>{channel_language}</dc:language>
    <dc:creator>{email}</dc:creator>
    <dc:rights>Copyright {gmt_date format="%Y"}</dc:rights>
    <dc:date>{gmt_date format="%Y-%m-%dT%H:%i:%s%Q"}</dc:date>
    <admin:generatorAgent rdf:resource="http://expressionengine.com/" >
{exp:channel:entries channel="about" limit="19" rdf="off" dynamic_start="on" status="open" disable="member_data|trackbacks"}
<item>
{categories}
{if channel_id=="1" AND category_id=="3"}

      <title>{exp:xml_encode}{title} -- Arts Section -- {category_name} {/exp:xml_encode}</title>
      <link>{title_permalink=arts_section/arts_articles_books}</link>
      <guid>{title_permalink=arts_section/arts_articles_books}</guid>
      <description>{exp:xml_encode}{article}{/exp:xml_encode}</description>
      <dc:subject>{exp:xml_encode}{category_name}, {/exp:xml_encode}</dc:subject>
      <dc:date>{gmt_entry_date format="%Y-%m-%dT%H:%i:%s%Q"}</dc:date>
{/if}
{/categories} 
    </item>
{/exp:channel:entries}
    </channel>
</rss>
{/exp:rss:feed}

But- there is a problem spot- <dc:subject>{exp:xml_encode}{category_name}, {/exp:xml_encode}</dc:subject> - without the nested tag, that’s only going to be the single current category name.

       
tbritton's avatar
tbritton
714 posts
9 years ago
tbritton's avatar tbritton

Thanks, Robin. I’ll do some tests without that nested tag. (I thought it was the only one that was working!!!)

Now I see - nested tags are a no-no there.

I may still need to do some tests for further sifting, but I’ll let you know how it goes.

Thanks so much - it was the last thing I suspected!

I did not know {exp:xml_encode} still worked! (Couldn’t find documentation on it, so I assumed it was part of the problem.)

Terry

       
Robin Sowell's avatar
Robin Sowell
13,159 posts
9 years ago
Robin Sowell's avatar Robin Sowell

I actually thought in your simplified example it might work- but no love. The original example could have left stray open conditionals, so it’s actually good that it broke. For a relative value of good!

And I did have to go to ‘Add-ons’ and click ‘install’ for both the RSS and XML Encodes add-ons. It’s certainly worth double checking those.

But my simple example- modified for the correct params and conditional values- should work. So I’d use that to start- and once it’s working, hit the full template.

       
Rural Intelligence's avatar
Rural Intelligence
18 posts
9 years ago
Rural Intelligence's avatar Rural Intelligence

Robin,

It is behaving a heck of a lot better now!

Thankfully, search and replace fixed the major transgressions.

http://ruralintelligence.com/index.php/feed/RSS_2.0

Now to work on the Atom feed, but I think we are in the right direction now.

Thanks a billion or so!

Terry

       
Rural Intelligence's avatar
Rural Intelligence
18 posts
9 years ago
Rural Intelligence's avatar Rural Intelligence

Hooray! Atom feeds work now as well!!!

Time to go celebrate. This has been nerve wracking for days! 😊

Terry

       
tbritton's avatar
tbritton
714 posts
9 years ago
tbritton's avatar tbritton

Marked as FIXED! 😊

Terry

       
Robin Sowell's avatar
Robin Sowell
13,159 posts
9 years ago
Robin Sowell's avatar Robin Sowell

We need some celebrate icons or something!

YAY for fixed! 😉

       
tbritton's avatar
tbritton
714 posts
9 years ago
tbritton's avatar tbritton
We need some celebrate icons or something! YAY for fixed! 😉

I’ll second that feature request! :-D

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.