Иногда валидаторы ругаются, иногда агрегаторы, иногда хостер(сервер) 500 выдает.
Проблема:
Создаем rss ленту (модуль Calguys Feed Maker) допустим код валидный все хорошо но заголовок:
Code: Select all
Server: nginx/0.6.34
Date: Fri, 10 Apr 2009 19:48:35 GMT
[b]Content-Type: text/xml;[/b] charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
X-Powered-By: PHP/5.2.8
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Content-Language: ru-RU
[b]500 [/b]Internal Server Error
Надо перебить Content type.
Создаем Тег пользователя xmlheader с кодом
Code: Select all
global $gCms;
$variables = &$gCms->variables;
$variables['content-type'] = 'application/xml';
Code: Select all
{xmlheader}<?xml version="1.0"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel> ....
Code: Select all
Server: nginx/0.6.34
Date: Fri, 10 Apr 2009 19:54:51 GMT
[b]Content-Type: application/xml;[/b] charset=utf-8
.....
500 Internal Server Error

В общем благодаря подсказке Сони на content_dump (правда он почему то "дублит" контент т.е. каждую страницу выводит два раза в дамп) я решил заделать мегафид (сбылась мечта) чтобы и новости и альбомы (правда альбомы пришлось выводить вручную) там с картинками и обычные страницы (они ж обновляются иногда). Зачем? Ну фиды можно добавлять в агрегаторы, а агрегаторы индексируются и теоретически можно получить крупицу ссылочного счастья.
Вот шаблон мультифида:
Code: Select all
{xmlheader}<?xml version="1.0"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
{* note: if you have not configured pretty urls or mod rewrite, the next line may fail when trying to validate the feed *}
<atom:link href="{$feed_url}" rel="self" type="application/rss+xml" />
<title>{$feed.title}</title>
{if isset($feed.link) && !empty($feed.link)}<link>{$feed.link}</link>{/if}
{if isset($feed.description) && !empty($feed.description)}<description>{$feed.description}</description>{/if}
{if isset($feed.copyright) && !empty($feed.copyright)}<copyright>{$feed.copyright}</copyright>{/if}
{if isset($generator)}<generator>{$generator}</generator>{/if}
{if isset($feed.managing_editor) && !empty($feed.managing_editor)}<managingEditor>{$feed.managing_editor}</managingEditor>{/if}
{if isset($admin_email)}<webMaster>{$admin_email} ({$admin_user->firstname} {$admin_user->lastname})</webMaster>{/if}
{if isset($feed.image) && !empty($feed.image)}
<image>
{if isset($feed.description) && !empty($feed.description)}<description>{$feed.description}</description>{/if}
{if isset($feed.link) && !empty($feed.link)}<link>{$feed.link}</link>{/if}
<title>{$feed.title}</title>
<url>{$file_location}/{$feed.image}</url>
</image>
{/if}
{* an example of how to create a feed from a call to the news module *}
{news assign='junk'}
{foreach from=$items item='entry'}
<item>
<title>{$entry->title|cms_html_entity_decode}</title>
<link>{$entry->moreurl}</link>
{capture assign='description'}{if isset($entry->summary)}{$entry->summary}{else}{$entry->content}{/if}{/capture}
<description>{$description|trim|strip_tags|summarize:40}</description>
<pubDate>{$entry->postdate|rfc_date}</pubDate>
<guid>{$entry->moreurl}</guid>
</item>
{/foreach}
{* an example of how to create a feed from a call to the album module *}
{capture assign='portfolio'}
{cms_module module='album' detailpage='portfolio' sortpicturesdesc='true' albums='4' action='random_image' number='3'}
{/capture}
{foreach from=$pictures item='entry'}
<item>
<title>{$entry->name}</title>
<link>{$feed.link}</link>
<description>
<![CDATA[<a href="{$feed.link}"<img src="{$entry->thumbnail}" alt="{$entry->comment|strip_tags|truncate:150}" width="{$entry->thumbnailwidth}" height="{$entry->thumbnailheight}"/></a><br/>
{$entry->comment|strip_tags|truncate:150} {$entry->comment2|strip_tags|truncate:150} {$entry->comment3|strip_tags|truncate:150}
<hr />]]>
</description>
</item>
{/foreach}
{capture assign='photogallery'}
{cms_module module='album' sortpicturesdesc='true' albums='5' action='random_image' number='3'}
{/capture}
{foreach from=$pictures item='entry'}
<item>
<title>{$entry->name}</title>
<link>{$feed.link}</link>
<description>
<![CDATA[<a href="{$feed.link}"<img src="{$entry->thumbnail}" alt="{$entry->comment|strip_tags|truncate:150}" width="{$entry->thumbnailwidth}" height="{$entry->thumbnailheight}"/></a><br/>
{$entry->comment|strip_tags|truncate:150} {$entry->comment2|strip_tags|truncate:150} {$entry->comment3|strip_tags|truncate:150}<hr />]]>
</description>
</item>
{/foreach}
{* an example of how to create a feed from a call to the content_dump (e.g. content) module exclude album news and badworking with do_smarty pages*}
{content_dump assign='contentdump' first_sort_order='down' exclude='15,16,20,22' do_smarty='compile'}
{assign var='previd' value=0} {*exclude doubles*}
{foreach from=$contentdump item='entry'}
{if $previd ne $entry->content->id}{*exclude doubles*}
{assign var='previd' value=$entry->content->id}{*exclude doubles*}
<item>
<title>{$entry->content->title|strip_tags}</title>
<link>{$feed.link}/{$entry->content->alias}.html</link>
<description>
<![CDATA[
{$entry->content->data|strip_tags|truncate:400}
]]>
</description>
</item>
{else} {*exclude doubles*}
{*exclude doubles*}
{/if} {*exclude doubles*}
{/foreach}
</channel>
</rss>