Турбо страницы для DLE
Для правильной работы Турбо страниц в Яндексе необходимо, чтобы в rss.xml были теги
<turbo:content><![CDATA[{full-story}]]></turbo:content>
между которыми выводилось форматирование полной новости (абзацы, картинки, подзаголовки и тд). В DLE, начиная с версии 12.1, все работает по умолчанию, но в более ранних версиях надо вносить доработки.
Установка:
1. Заменить ваш templates/rss.tpl файлом из архива.
2. Открыть engine/rss.php и найти:
<rss xmlns:yandex="http://news.yandex.ru" xmlns:media="http://search.yahoo.com/mrss/" version="2.0">
Заменить на:
<rss xmlns:yandex="http://news.yandex.ru" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:turbo="http://turbo.yandex.ru" version="2.0">
3. Открыть engine/modules/show.short.php и найти:
if( $view_template == "rss" ) {
Или для DLE 10.х и старше:
if( isset($view_template) AND $view_template == "rss" ) {
И ниже:
$tpl->set( '{full-story}', $row['full_story'] );
Код между ними, включая эти строки, заменить на:
if( $view_template == "rss" ) {
$tpl->set( '{rsslink}', $full_link );
$tpl->set( '{rssauthor}', $row['autor'] );
$tpl->set( '{rssdate}', date( "r", $row['date'] ) );
$tpl->set( '{title}', str_replace("&amp;", "&", htmlspecialchars( strip_tags( stripslashes( $row['title'] ) ), ENT_QUOTES, $config['charset'] ) ) );
$row['full_story'] = stripslashes( $row['full_story'] );
if( strlen($row['full_story']) < 13 ) $row['full_story'] = $row['short_story'];
$row['short_story'] = preg_replace( "'\[attachment=(.*?)\]'si", "", $row['short_story'] );
$row['short_story'] = preg_replace ( "#\[hide(.*?)\](.+?)\[/hide\]#is", "", $row['short_story'] );
if( $config['rss_format'] != 1 ) {
$row['short_story'] = preg_replace( "#<!--(.+?)-->#is", "", $row['short_story'] );
$tpl->set("<![CDATA[{short-story}]]>", "<![CDATA[".$row['short_story']."]]>");
$row['short_story'] = str_replace( "><", "> <", $row['short_story'] );
$row['short_story'] = trim(htmlspecialchars( strip_tags( str_replace( array("<br>", "<br />"), " ", $row['short_story'] ) ), ENT_QUOTES, $config['charset'] ) );
$row['short_story'] = preg_replace('/\s+/', ' ', $row['short_story']);
$tpl->set( '{short-story}', $row['short_story']);
} else {
$row['short_story'] = preg_replace( "#<!--(.+?)-->#is", "", $row['short_story'] );
$tpl->set( '{short-story}', $row['short_story'] );
}
if( $config['rss_format'] == 2 ) {
$images = array();
$row['full_story'] = stripslashes( $row['full_story'] );
preg_match_all('/(img|src)=("|\')[^"\'>]+/i', $row['full_story'], $media);
$data=preg_replace('/(img|src)("|\'|="|=\')(.*)/i',"$3",$media[0]);
foreach($data as $url) {
$info = pathinfo($url);
if (isset($info['extension'])) {
if ($info['filename'] == "spoiler-plus" OR $info['filename'] == "spoiler-minus" OR strpos($info['dirname'], 'engine/data/emoticons') !== false) continue;
$info['extension'] = strtolower($info['extension']);
if (($info['extension'] == 'jpg') || ($info['extension'] == 'jpeg') || ($info['extension'] == 'gif') || ($info['extension'] == 'png')) { if($info['extension'] == 'jpg') $info['extension'] ='jpeg'; array_push($images, "<enclosure url=\"{$url}\" type=\"image/{$info['extension']}\" />"); }
}
}
if ( count($images) ) {
$tpl->set( '{images}', "\n".implode("\n", $images) );
} else { $tpl->set( '{images}', '' ); }
}
$row['full_story'] = preg_replace( "#<!--(.+?)-->#is", "", $row['full_story'] );
$row['full_story'] = preg_replace( "'\[attachment=(.*?)\]'si", "", $row['full_story'] );
$row['full_story'] = preg_replace ( "#\[hide(.*?)\](.+?)\[/hide\]#is", "", $row['full_story'] );
$tpl->set("<![CDATA[{full-story}]]>", "<![CDATA[".$row['full_story']."]]>");
$row['full_story'] = str_replace( "><", "> <", $row['full_story'] );
$row['full_story'] = trim (htmlspecialchars( strip_tags( stripslashes( str_replace( array("<br>", "<br />"), " ", $row['full_story'] ) ) ), ENT_QUOTES, $config['charset'] ) );
$row['full_story'] = preg_replace('/\s+/', ' ', $row['full_story']);
$tpl->set( '{full-story}', $row['full_story'] );
} else {
Готово!
• Кодировка: utf-8
• Источник
Посетители, находящиеся в группе Гость, не могут оставлять комментарии к данной публикации.
Комментариев 1