Skip to content

Instantly share code, notes, and snippets.

@b0n
Last active August 29, 2015 14:14
Show Gist options
  • Save b0n/75e407ad56848ef60ae8 to your computer and use it in GitHub Desktop.
Save b0n/75e407ad56848ef60ae8 to your computer and use it in GitHub Desktop.
smartyからssi呼び出し。テンプレと出力が異文字コード。 ref: http://qiita.com/mrk461/items/016822ebf827f8b7b31e
<?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;
}
{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