Skip to content

Instantly share code, notes, and snippets.

@TrywaR
Last active July 7, 2019 22:07
Show Gist options
  • Save TrywaR/1eae3a6d8ac91ed7737b3ab19eded861 to your computer and use it in GitHub Desktop.
Save TrywaR/1eae3a6d8ac91ed7737b3ab19eded861 to your computer and use it in GitHub Desktop.
MODX Revo > RSS для турбо-страниц хуяндекса

MODX Revo > RSS для турбо-страниц хуяндекса

  1. Создаём страницу, тип содержимого XML, шаблон пустой, содержимое в файле содержимое страницы.xml где заменяем tv поля для картинки под нужное, и заменяем id 3 на те ресурсы которые нужно выводить
  2. Создаём сниппет htmlspecialchars с содержимым htmlspecialchars.php для экранизации тегов и замены путей картинок на полные, нужно в сниппете указать путо до картинок
  3. Создаём чанк rss.item для вывода результатов, содержимое для него в файле rss.item.tpl где заменяем если нужно tv поля для вывода картинок
  • Данный способ выводить RSS не только для хуяндекса, а куда угодно
<?php
if (isset($content)){
$image_path = 'img'; # Папка с картинками
$output = str_replace( 'src="'.$image_path, 'src="[[++site_url]]'.$image_path, $content );
$output = htmlspecialchars($output);
return $output;
}
<item turbo="true">
<link>[[++site_url]][[+uri]]</link>
<title>[[+longtitle:default=`[[+pagetitle]]`]]</title>
<pubDate>[[+createdon:date=`%a, %d %b %Y %H:%M:%S +0300`]]</pubDate>
<author>TrywaR</author>
<description>
[[htmlspecialchars? &content=`[[+introtext]]`]]
[[+tv.img:notempty=`<img src="[[++site_url]][[+tv.img]]" />`]]
</description>
<content>
[[htmlspecialchars? &content=`[[+content]]`]]
[[+tv.img:notempty=`<img src="[[++site_url]][[+tv.img]]" />`]]
</content>
</item>
<item turbo="true">
<link>[[++site_url]][[+uri]]</link>
<title>[[+longtitle:default=`[[+pagetitle]]`]]</title>
<pubDate>[[+createdon:date=`%a, %d %b %Y %H:%M:%S +0300`]]</pubDate>
<author>TrywaR</author>
<turbo:topic>[[+id]]</turbo:topic>
<turbo:content>
<header>
[[+tv.img:notempty=`<figure><img src="[[+tv.img]]" /></figure>`]]
<h1>
[[htmlspecialchars? &content=`[[+longtitle:default=`[[+pagetitle]]`]]`]]
</h1>
</header>
[[htmlspecialchars? &content=`[[+content]]`]]
</turbo:content>
</item>
<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:yandex="http://news.yandex.ru" xmlns:media="http://search.yahoo.com/mrss/" xmlns:turbo="http://turbo.yandex.ru" version="2.0">
<channel>
<title>[[++site_name]]</title>
<link>[[++site_url]]</link>
<description>[[#3.description]]</description>
<language>ru</language>
[[!pdoPage?
&parents=`3`
&tpl=`rss.item`
&includeContent=`1`
&includeTVs=`img`
]]
</channel>
</rss>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment