Skip to content

Instantly share code, notes, and snippets.

@zorgsoft
Last active March 1, 2021 13:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zorgsoft/d6141c76d25b05b6f4062436c657a9e9 to your computer and use it in GitHub Desktop.
Save zorgsoft/d6141c76d25b05b6f4062436c657a9e9 to your computer and use it in GitHub Desktop.
MODx Evo DocLister RSS
<?php
// Сниппет date
// Форматирование даты
if(!isset($en)){
setlocale(LC_ALL, 'ru_RU.UTF-8', 'ru', 'russian');
} else {
setlocale(LC_ALL, 'en_US.UTF-8', 'en', 'english');
}
$date = isset($date)?(isset($sqldate)?$date:strtotime($date)):time();
return strftime(isset($format)?$format:'%d-%m-%Y', $date);
<?xml version='1.0' encoding='utf-8' ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<atom:link href="[(site_url)]rss" rel="self" type="application/rss+xml" />
<title>c0der.ru</title>
<link>[(site_url)]</link>
<description>[(site_name)]</description>
<language>ru-ru</language>
<generator>Hands</generator>
<managingEditor>[(emailsender)] (c0der)</managingEditor>
<webMaster>[(emailsender)] (c0der)</webMaster>
<image>
<url>[(site_url)]avatar_logo.jpg</url>
<title>c0der.ru</title>
<link>[(site_url)]</link>
</image>
[!DocLister?
&display=`100`
&summary=`len:600,notags`
&dotSummary=`0`
&dateSource=`pub_date`
&parents=`7`
&urlScheme=`full`
&depth=`3`
&tvList=`photo,tag`
&id=`rss`
&dateFormat=`%a, %d %b %Y %H:%M:%S %z`
&tplId1=`rss_list_first_item`
&tpl=`rss_list_item`
&filters=`AND(content:template:is:4)`
!]
</channel>
</rss>
<item>
<title>[+e.title+]</title>
<link>[+url+]</link>
<guid isPermaLink='true'>[+url+]</guid>
<description>[+summary+]</description>
<category>[[DocInfo? &docid=`[+parent+]` &field=`pagetitle`]]</category>
<pubDate>[[date? &date=`[+createdon+]` &sqldate=`1` &format=`%a, %d %b %Y %H:%M:%S %z` &en=`true`]]</pubDate>
</item>
<lastBuildDate>[[date? &date=`[+createdon+]` &sqldate=`1` &format=`%a, %d %b %Y %H:%M:%S %z` &en=`true`]]</lastBuildDate>
<item>
<title>[+e.title+]</title>
<link>[+url+]</link>
<guid isPermaLink='true'>[+url+]</guid>
<description>[+summary+]</description>
<category>[[DocInfo? &docid=`[+parent+]` &field=`pagetitle`]]</category>
<pubDate>[[date? &date=`[+createdon+]` &sqldate=`1` &format=`%a, %d %b %Y %H:%M:%S %z` &en=`true`]]</pubDate>
</item>
@zorgsoft
Copy link
Author

zorgsoft commented Mar 1, 2021

I have a question:

I just converted a Ditto call using your RSS feed, but the Doclister call is simply rendered in the page source

Could you tell me how the page / document is setup for your call ?

Your help is much appreciated

In page (document) settings select content type "application/rss+xml".

image

@modxuser
Copy link

modxuser commented Mar 1, 2021

@zorgsoft

That's great, thanks

I found the problem:

Using code directly in the "&tpl" call kept rendering the whole Doclister call in the front-end

Once the template code was in a chunk the call worked perfectly using "application/rss+xml" or "text/xml"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment