RSSをごにょる
参考
結局smartyにXML書く方法にした
php
//hogehoge //mogemoge // header("Content-Type: application/xml;charset=UTF-8"); $tpl = "mag/rss2.xml" ; $smarty->assign('category', $category); $smarty->assign('entries', $entries); $smarty->display( $tpl ) ;
smarty
<?xml version="1.0" encoding="utf-8" ?> <rss version="2.0"> <channel> <title>{$category->name|mb_convert_encoding:"UTF-8":"AUTO"|escape:"html"}</title> <link>{$smarty.const.SYSTEM_URL}?no={$category->no|escape}</link> <description></description> <language>ja</language> {foreach from="$entries" item="entry"} <item> <title>{$entry->title|mb_convert_encoding:"UTF-8":"AUTO"|escape}</title> <description> <![CDATA[ {$entry->description|mb_convert_encoding:"UTF-8":"AUTO"} ]]> </description> <link>{$smarty.const.SITEDOMAIN}entry.php?no={$entry->no|escape}</link> <pubDate>{$entry->pub_date|date_format:"%A, %B %e, %Y %T +0900" }</pubDate> </item> {/foreach} </channel> </rss>
一応phpの方でheaderを指定した。
サイトがUTFでないので
smartyにフィルタいれた
class SmartyRss extends Smarty { function __construct(){ parent::Smarty_fumi(); $this->register_prefilter('toUTF8'); } } function toUTF8($buff, &$smarty){ return mb_convert_encoding($buff, "UTF-8", "AUTO"); }