How can I create a view that displays real XML content for an RSS feed. I use SLIM, TWIG for templates in combination with Paris and Idiorm.
Sort of:
$app -> get('/rss/', function() use ($app) { $articles = Model::factory('Article') -> order_by_desc('timestamp') -> find_many(); return $app -> render('rss.xml', array('articles' => $articles)); });
With this layout.xml template:
<?xml version="1.0" encoding="UTF-8"?> {% block content %} {% endblock %}
And this special template for the RSS route:
{% extends 'layout.xml' %} {% block content %} <blog_content> {% for article in articles %} <article> <article_id>{{ article.id }}</article_id> <article_headline>{{ article.title }}</article_headline> <article_author>{{ article.author }}</article_author> <article_timestamp>{{ article.timestamp }}</article_timestamp> <article_summary>{{ article.summary }}</article_summary> <article_link>http://slim.phaziz.com/article/{{ article.id }}/</article_link> </article> {% endfor %} </blog_content> {% endblock %}
Will display as an HTML Doument that contains Templates as Body Text ... The header is always sent as xHTML, not XML
???
Thanx for help!
source share