MarkupRSS
Renders an RSS2 feed from a PageArray of pages
Designed to be called directly from a template file — set the feed properties, pass your pages, call render(), and exit.
$rss = $modules->get('MarkupRSS');
$rss->setArray([
'title' => 'Latest updates',
'description' => 'The most recently updated pages',
'itemTitleField' => 'title',
'itemDateField' => 'modified',
'itemDescriptionField' => 'summary',
'itemDescriptionLength' => 1000,
'itemContentField' => 'body', // optional full HTML content
'itemAuthorField' => 'createdUser',
]);
$rss->render($pages->find('template=blog-post, limit=10, sort=-modified'));
exit; The module is configurable — all settings can be set via the module configuration screen (Admin → Modules → Markup Extends WireData. Implements Expand all Collapse all API reference All properties are read/write and can be set via Sends the Renders the complete RSS feed XML and returns it as a string — without sending HTTP headers or echoing. Use this when you need control over output (custom headers, caching, logging, etc.). Returns the module configuration form used in Admin → Modules → Markup The item title comes from Publish date uses Two modes depending on When When The XML element is Pages that are not viewable ( When the module is already configured in Admin → Modules → Markup This is intended to be used directly from a template file. See usage below. USAGE See also the $defaultConfigData below (first thing in the class) to see what
options you can change at runtime. Click any linked item for full usage details and examples. Hookable methods are indicated with the icon. In addition to those shown below, the Render the feed and echo it (with proper http header) Render the feed and return it In addition to the methods and properties above, MarkupsetArray(), set(), or direct property access.Module and ConfigurableModule.$rss->set('key', $value), $rss->key = $value, or $rss->setArray([...]).Property Type Default Description titlestring'Untitled RSS Feed'Feed title ( <channel><title>)urlstring''Feed URL ( <channel><link>); falls back to current page's httpUrl when emptydescriptionstring''Feed description ( <channel><description>)copyrightstring''Optional copyright notice; omitted from XML when empty ttlint60Time-to-live in minutes; how long the feed may be cached before refreshing xslstring''Optional URL to an XSL stylesheet for browser display cssstring''Optional URL to a CSS stylesheet headerstring'Content-Type: application/xml; charset=utf-8;'HTTP header sent by render()itemTitleFieldstring'title'Page field to use for each item's <title>itemDateFieldstring'created'Field for <pubDate> — a datetime field, or 'created', 'modified', 'published'itemDescriptionFieldstring'summary'Page field for <description>itemDescriptionLengthint1024Max description length; set to 0 to allow HTML with no truncationitemContentFieldstring''Optional page field for full HTML in <content:encoded>itemAuthorFieldstring''Optional page field for author (text, Page, or PageArray) itemAuthorElementstring'dc:creator'XML element for author — 'dc:creator' or 'author'stripTagsbooltrueStrip HTML tags from description when itemDescriptionLength > 0feedPagesarray|PageArray[]The pages to render; typically passed to render() or renderFeed()render(?PageArray $feedPages = null)
Content-Type: application/xml HTTP header, renders the feed, echoes it, and returns true. Pass a PageArray directly, or set feedPages beforehand. Call exit after this to prevent further output from corrupting the XML.$rss = $modules->get('MarkuprenderFeed(?PageArray $feedPages = null)
$xml = $rss->renderFeed($pages->find('template=news, limit=20, sort=-created'));
header('Content-Type: application/xml; charset=utf-8');
echo $xml;
exit;getModuleConfigInputfields(array $data)
Titles
itemTitleField (default title). HTML tags are stripped. If a page has an empty title, the entire item is skipped from the feed.Dates
getUnformatted() on itemDateField to obtain a raw Unix timestamp, then formats it as RFC 2822 (DATE_RSS). Built-in options: 'created', 'modified', 'published', or any datetime field name. If the timestamp evaluates to falsy (e.g., empty field), no <pubDate> is emitted for that item.Descriptions
itemDescriptionLength:1024): HTML entities are decoded, tags are stripped (unless stripTags is false), and the text is intelligently truncated — it tries to end at punctuation (., ?, !, ,, ;) or at a word boundary. The result is XML-escaped.href/src attributes are converted to absolute. This preserves HTML formatting.// Truncated text descriptions (default behavior)
$rss->itemDescriptionLength = 500;
// Full HTML descriptions (no truncation, no tag stripping)
$rss->itemDescriptionLength = 0;Full content
itemContentField is set, the field's HTML is included in a <content:encoded> CDATA element alongside the <description>. The relative-to-absolute conversion converts href="/..." and src="/..." to absolute URLs using the site root, and href="#..." anchors to absolute page URLs with fragments.$rss->itemContentField = 'body'; // include full article body as <content:encoded>Authors
itemAuthorField is set, the module supports:title|name (first non-empty).,.dc:creator by default. Change to 'author' via itemAuthorElement (use 'author' when the value is an email address to comply with RSS spec).$rss->itemAuthorField = 'createdUser'; // use page author
$rss->itemAuthorElement = 'author'; // use <author> element instead of <dc:creator>Viewability filtering
$page->viewable() returns false) are automatically skipped — the module respects page status, access control, and any viewable hooks.Blog feed with full content
$rss = $modules->get('MarkupPre-configured from module settings
$modules->get('MarkupReturn-only (no output)
$rss = $modules->get('Markupexit after render() in a template file — any further output will corrupt the XML.url property defaults to the current page's httpUrl when left blank (set in renderHeader()).xmlns:atom, xmlns:dc, and xmlns:content (the latter only when itemContentField is set).<, >, &, ", ' are emitted as hexadecimal entities (>, &, etc.).<![CDATA[ and ]]> markers in source HTML content are escaped to prevent breaking the outer CDATA wrapper.itemAuthorField, itemAuthorElement, and stripTags properties are not exposed in the module config screen — set them via the API only.wire/modules/Markup/Markupget, set, setArray, etc.) is available.API reference: methods, properties
$rss = $modules->get('MarkupMarkup class also inherits all the methods and properties of: WireData and Wire.Common
Name Return Summary bool string Properties
Name Return Summary Markup string Markup string Markup string Markup array PageArray Markup string Markup string Markup string Markup string Markup string Markup string Field to use for item description. Markup int Max length for item description or 0 to allow HTML markup with any length
DEFAULT: 1024 Markup string Markup bool Strip tags from item description? Applies only if itemDescriptionLength>0.
DEFAULT: true Markup string Markup int Markup string Markup string Additional methods and properties
API reference based on ProcessWire core version 3.0.269