Created
June 22, 2016 07:13
-
-
Save RyujiAMANO/cef9138b14faed29df9beb89d6501855 to your computer and use it in GitHub Desktop.
HTML置換プリロード
This file contains 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 | |
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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
普通はこんなん使うよりテーマごとのcss側でdisplay:noneしちゃったほうがいいです。picoとかコンテンツ中にかかれてるjavascriptとかstyleタグとかを無視させたくなったんでつくりました