帝国CMS做站常用代码整理

时间:2023年11月10日

/

来源:网络

/

编辑:佚名

帝国cms实用功能代码集合,获取栏目网址 ,判断是否当前页(高亮),判断是否首页(用于高亮)等
获取栏目网址:
$classurl=sys_ReturnBqClassname($bqr,9);//取得栏目地址
判断是否首页(用于高亮):
<?=(!$GLOBALS[navclassid])?' class="cur"':''?>
判断是否当前页(高亮):
<?=($GLOBALS[navclassid]==$bqr[classid])?' class="cur"':''?>
各页面自动跳转移动端:
<script src="http://siteapp.baidu.com/static/webappservice/uaredirect.js" type="text/javascript"></script>
<?php
/*判断首页或者列表或者内页自动生成跳转地址,,,,,如果不生效就把百度这个js文件保存在网站本地*/
if(!$GLOBALS[navclassid])
{
?>
<script type="text/javascript">uaredirect("http://m.xxx.com");</script>
<?php
}
else
{
?>
<script type="text/javascript">uaredirect("http://m.xxx.com/<?=$class_r[$GLOBALS['navclassid']]['classpath']?>/<?=($navinfor[id]?$navinfor[id].'.html':'')?>");</script>
<?php
}
?>
按照指定排序调用SQL语句片段(配合条件调用):
order by field(classid,10,3,4,41,40)
栏目导航中判断某栏目是否为终极栏目:
if ($bqr[sonclass]=='' or $bqr[sonclass]=="|")
...
补充1:
判断当前栏目是否有设置标题分类并调用:
<?php
//判断当前栏目是否有设置标题分类
$tr=$empire->fetch1("select ttids from phome_enewsclassadd where classid=$GLOBALS[navclassid]");
//上面这句如果用在标题分类列表页需要改为$tr=$empire->fetch1('select ttids from phome_enewsclassadd where ttids like "%'.$GLOBALS[navclassid].'%"');
if ($tr[ttids]){
?>
<div class="am-panel-bd" style=" padding:15px 5px; overflow:hidden;">
<?
$ttids=explode(',',trim($tr[ttids],","));
foreach($ttids as $id){
$ttname_sql=sys_ReturnEcmsLoopBq("select * from [!db.pre!]enewsinfotype where typeid=$id",0,24,0);
while($bqr2=$empire->fetch($ttname_sql)){
$tturl=sys_ReturnBqInfoTypeUrl($bqr2[typeid]);
?>
<a class="ys4" href="<?=$tturl?>" target="_blank"><?=$bqr2[tname]?></a>
<?php
}//endwhile
}//endfor
?>
</div>
<?
}//ENDIF
?>
[2018.6.5]补充2:
禁止页面被复制和禁止右键:
<style type="text/css">
body {
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
</style>
<script langauge="javascript">
document.oncontextmenu=function(e){return false;}
</script>
</head>
猜你需要

豫ICP备2021026617号-1  豫公网安备:41172602000185   Copyright © 2021-2028 www.78moban.com/ All Rights Reserved

本站作品均来自互联网,转载目的在于传递更多信息,并不代表本站赞同其观点和对其真实性负责。如有侵犯您的版权,请联系 1565229909#qq.com(把#改成@),我们将立即处理。