Last active
December 7, 2021 06:32
-
-
Save adrienne/5265547 to your computer and use it in GitHub Desktop.
EE sample feed; multiple entries if no third segment, otherwise comments from single entry. REQUIRES STASH.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="{charset}"?> | |
<rss version="2.0" | |
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/" | |
xmlns:atom="http://www.w3.org/2005/Atom" | |
xmlns:ee="http://ellislab.com/"> | |
{preload_replace:pre_maintitle="A Title for the Feed"} | |
{preload_replace:pre_eechannel="channel_name"} | |
{preload_replace:pre_bodyfield="body"} | |
{preload_replace:pre_summfield="summary"} | |
{preload_replace:pre_commentsegment="view"} | |
{preload_replace:pre_catsegment="category"} | |
{preload_replace:pre_copyrightnotice="Somebody, All Rights Reserved"} | |
{preload_replace:pre_copyrightstartyear="2011"} | |
{exp:channel:info channel="{pre_eechannel}"} | |
{exp:stash:set name="this_channeldesc"}{channel_description}{/exp:stash:set} | |
{exp:stash:set name="this_mainurl"}{path='{channel_url}'}/{/exp:stash:set} | |
{exp:stash:set name="this_commenturl"}{path='{channel_url}{pre_commentsegment}'}/{/exp:stash:set} | |
{exp:stash:set name="this_categoryurl"}{path='{channel_url}{pre_catsegment}'}/{/exp:stash:set} | |
{/exp:channel:info} | |
{exp:rss:feed channel="{pre_eechannel}"} | |
<channel> | |
{exp:channel:entries channel="{pre_eechannel}" limit="10" disable="member_data|pagination"} | |
{if count == 1} | |
<title>{exp:xml_encode}{pre_maintitle}{if segment_3 != ""} : {title} : Comments{/if}{/exp:xml_encode}</title> | |
<link>{if segment_3 != ''}{exp:stash:get name='this_commenturl'}{url_title}{if:else}{exp:stash:get name='this_mainurl'}{/if}</link> | |
<description><![CDATA[{if segment_3 != ""}{exp:eehive_hacksaw words="150" append="..."} | |
{{pre_summfield}} | |
{/exp:eehive_hacksaw}{if:else}{exp:stash:get name='this_channeldesc'}{/if}]]></description> | |
<dc:language>{lang}</dc:language> | |
<dc:creator>[email protected]</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> | |
<copyright><![CDATA[Copyright {pre_copyrightstartyear}—{current_time format='%Y'}, {pre_copyrightnotice}]]></copyright> | |
<atom:link href="{if segment_3 != ''}{exp:stash:get name='this_commenturl'}{url_title}{if:else}{exp:stash:get name='this_mainurl'}{/if}" rel="self" type="application/rss+xml" /> | |
<admin:generatorAgent rdf:resource="http://expressionengine.com/" /> | |
{categories}<category domain="{exp:stash:get name='this_categoryurl'}{category_url_title}"><![CDATA[{category_name}]]></category>{/categories} | |
{/if} | |
{if segment_3 != ""} | |
{exp:comment:entries} | |
<item> | |
<title>{exp:xml_encode}{name} commented on {title}{/exp:xml_encode}</title> | |
<link>{exp:stash:get name='this_commenturl'}{url_title}#comment-{comment_id}</link> | |
<guid isPermaLink="true">{exp:stash:get name='this_commenturl'}{url_title}#comment-{comment_id}</guid> | |
<description><![CDATA[{comment}]]></description> | |
<dc:date>{gmt_entry_date format="%Y-%m-%dT%H:%i:%s%Q"}</dc:date> | |
</item> | |
{/exp:comment:entries} | |
{if:else} | |
<item> | |
<title><![CDATA[{title}]]></title> | |
<link>{exp:stash:get name='this_commenturl'}{url_title}</link> | |
<guid isPermaLink="true">{exp:stash:get name='this_commenturl'}{url_title}</guid> | |
<description><![CDATA[{{pre_bodyfield}}]]></description> | |
<dc:subject><![CDATA[{categories backspace="1"}{category_name}, {/categories}]]></dc:subject> | |
<dc:date>{gmt_entry_date format="%Y-%m-%dT%H:%i:%s%Q"}</dc:date> | |
{categories}<category domain="{exp:stash:get name='this_categoryurl'}{category_url_title}"><![CDATA[{category_name}]]></category>{/categories} | |
</item> | |
{/if} | |
{/exp:channel:entries} | |
</channel> | |
</rss> | |
{/exp:rss:feed} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment