Skip to content

Instantly share code, notes, and snippets.

@RyujiAMANO
Created June 22, 2016 07:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RyujiAMANO/cef9138b14faed29df9beb89d6501855 to your computer and use it in GitHub Desktop.
Save RyujiAMANO/cef9138b14faed29df9beb89d6501855 to your computer and use it in GitHub Desktop.
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;
}
@RyujiAMANO
Copy link
Author

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

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