Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
HTML置換プリロード
<?php
if (!defined('XOOPS_ROOT_PATH')) exit();
class htmlReplace extends XCube_ActionFilter
{
function preFilter()
{
$this->mRoot->mDelegateManager->add('XoopsTpl.New', array( &$this , 'xoopsTplHook' ) ) ;
}
function xoopsTplHook( &$xoopsTpl )
{
$xoopsTpl->register_outputfilter("htmlReplaceFilter");
}
}
function htmlReplaceFilter($tpl_output, &$smarty)
{
$replaced = $tpl_output;
if ($GLOBALS['xoopsConfig']['theme_set'] == 'smartphone'){
// 4PCを削除
$replaced = preg_replace('/<!--4PC-->.*?<!--\/4PC-->/s', '', $replaced);
}else{
// 4SMARTPHONEを削除
$replaced = preg_replace('/<!--4SMARTPHONE-->.*?<!--\/4SMARTPHONE-->/s', '', $replaced);
}
return $replaced;
}
Owner

RyujiAMANO commented Jun 22, 2016

普通はこんなん使うよりテーマごとのcss側でdisplay:noneしちゃったほうがいいです。picoとかコンテンツ中にかかれてるjavascriptとかstyleタグとかを無視させたくなったんでつくりました

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment