欢迎访问织梦学习网,加群!!!!!!!!!!!!!!!!
当前位置:主页 > 安装使用 >

dedecms首页弹出推荐产品弹窗

2018-03-14 dedecms安装使用 dedecms,首页,弹出,推荐产品,弹窗,目标,根据,

目标:根据后台定义的全局变量值(某一产品ID)前台页面自定开启该产品的弹窗
效果图:


操作步骤:
1、登陆到 网站后台,找到 系统 - 系统基本参数 - 添加新变量,按照下面的方式输入并创建该变量(注意:变量名不要输错)


1、打开 /wwwroot /include/ extend.func.php文件
在页面最底部插入以下代码:
//根据后台自定义变量自动判断首页是否弹出产品弹窗
function getPopProduct(){
    $poproID  = $GLOBALS['pop_product'];
    if(!empty($poproID) && $GLOBALS['pop_product'] != 0){
        $row = GetOneArchive($poproID);
        $poproTit = $row['title'];
        $poproUrl = $row['arcurl'];
        $poproDesc = $row['description'];
        $poproPic.= "<img WIDTH=250px; height=250px; src=".$row['litpic']." />";
        $popInfo .="<div class=pop><div class=pop_left>";
        $popInfo .= $poproPic."</div><div class=pop_right><span class=pop_title>".$poproTit."</span><p>".$poproDesc."</p><div class=pop_right3><a href=".$poproUrl." target=_blank>了解详情>></a></div></div>";
    }else{
        $popInfo = "";
        }
    echo $popInfo;
}

2 打开首页模板文件:

a、在<body>之前插入以下代码

{dede:php}
if(!empty($GLOBALS['pop_product']) && $GLOBALS['pop_product'] != 0){
    echo "<SCRIPT language='javascript' type='text/javascript' src='/templets/default/js/jquery.artDialog.min.js'></SCRIPT>";
    echo "<SCRIPT language='javascript' type='text/javascript' src='/templets/default/js/artDialog.plugins.min.js'></SCRIPT>";
    echo "<!--[if gte IE 7]><!--><LINK rel='stylesheet' type='text/css' href='/templets/default/js/simple.css'><!--<![endif]--><!--[if lt IE 7]><link href=/templets/default/js/default.css /><![endif]-->";
}
{/dede:php}
<script type="text/javascript" charset="utf-8">
      $(function() {
          $.dialog({width: '600px',
                   lock:true,
                   zIndex: 9999,
                   drag:true,
                   title:'最新产品推荐',
                   background:'#600',
                   opacity: 0.47,
                   esc:true,
                   content: document.getElementById('pop')
                    });
    });
</script>