Last active
August 29, 2015 14:14
-
-
Save b0n/75e407ad56848ef60ae8 to your computer and use it in GitHub Desktop.
smartyからssi呼び出し。テンプレと出力が異文字コード。 ref: http://qiita.com/mrk461/items/016822ebf827f8b7b31e
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* ssi | |
*/ | |
function smarty_function_ssi($params, &$smarty) | |
{ | |
if (empty($params['file'])) return ''; | |
if (empty($params['ssi_enc'])) return ''; | |
if (!file_exists($params['file'])) return '<!-- no file -->'; | |
$ssi = file_get_contents($params['file']); | |
if (false === $ssi) return ''; | |
/* | |
echo "<!--", PHP_EOL; | |
echo "******************************", PHP_EOL; | |
echo $ssi, PHP_EOL; | |
echo "******************************", PHP_EOL; | |
echo "-->", PHP_EOL; | |
*/ | |
$ret = mb_convert_encoding($ssi, mb_internal_encoding(), $params['ssi_enc']); | |
/* | |
echo "<!--", PHP_EOL; | |
echo "******************************", PHP_EOL; | |
echo $ret, PHP_EOL; | |
echo "******************************", PHP_EOL; | |
echo "-->", PHP_EOL; | |
*/ | |
return $ret; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ssi file="../design/ssi/head.html" ssi_enc="SJIS"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment