Search code examples
rssexpressionengine

ExpressionEngine 2 feed parser and the {title} conflict


Is there a way of disabling the {title} tag in ExpressionEngine 2? My client needs just one custom field, {rss_feed}, to add content.

I use the AJW Feed Parser Add-On to parse RSS feeds. The client just wants to add a RSS/Atom feed link in order for the web page to be populated with that specific feed.

The problem is that there's a conflict between the ExpressionEngine entry {title} and the {title} field from the AJW Feed Parser Add-On.

When I use the {title} template variable, the output is from ExpressionEngine's default {title} field not the AJW Feed Parser {title}.

My code looks like this:

{exp:channel:entries channel="blog" limit="1" dynamic="on" category="{embed:category}"}
    {exp:ajw_feedparser url="{blog_rss}" itempath="/feed/entry" cache_refresh="60" limit="1"}  
        <article>
            <header>
                <h1>{title}</h1>
                <time>{published format="%l, %j %F %Y at %G:%i"}</time>
                <a href="{author/uri}">{author/name}</a>
            </header>
            {content}
        </article>
    {/exp:ajw_feedparser} 
{/exp:channel:entries}

Is there another way of doing this with PHP?


Solution

  • This is why add-ons should include a "prefix" parameter, to avoid variable collisions like this.

    Regardless, you can solve this with an embed.

    {exp:channel:entries channel="blog" limit="1" dynamic="on" category="{embed:category}"}
        {embed="_embeds/blog_feed" url="{blog_rss}"}
    {/exp:channel:entries}
    

    Then your _embeds/blog_feed template looks like this:

    {exp:ajw_feedparser url="{embed:url_param}" itempath="/feed/entry" cache_refresh="60" limit="1"}  
        <article>
          <header>
            <h1>{title}</h1>
            <time datetime="2011-01-20T06:20:00-00:00">{published format="%l, %j %F %Y at %G:%i"}</time>
            <a href="{author/uri}">{author/name}</a>
          </header>
            {content}
        </article>
    {/exp:ajw_feedparser}