贺鸣 發表於 2024-3-2 00:00:00

织梦dedecms页面获取会员状态的方法

<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        本文实例讲述了dedecms页面获取会员状态的方法。分享给大家供大家参考。具体分析如下:</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        普通方法:导航栏增加了会员信息,如:已登陆:显示:欢迎&lt;会员名&gt; 未登陆 显示:请登录,代码如下:<br>
         </p>
<div class="msgheader" style='margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; font-family: tahoma, arial, "Microsoft YaHei";'>
        <div class="right">
                <span><u>复制代码</u></span>
</div>
        代码如下:</div>
<div class="msgborder" id="phpcode9" style='margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; font-family: tahoma, arial, "Microsoft YaHei";'>
        {dede:php} <br>
        require_once(DEDEMEMBER."/config.php"); <br>
        $uid = $cfg_ml-&gt;M_LoginID; <br>
        if(!$uid){ <br>
        echo '&lt;div&gt;&lt;a class="login-button" href="login.php"&gt;登录&lt;/a&gt; |&lt;a class="join-button" href="add.php"&gt;加入&lt;/a&gt;&lt;/div&gt;'; <br>
        }else{ <br>
        echo '&lt;div&gt; <br>
        &lt;a class="login-button" href="#"&gt;'.$uid.'&lt;/a&gt; |&lt;a class="join-button" href="&lt;?php echo $cfg_memberurl; ?&gt;/index_do.php?fmdo=login&amp;dopost=exit"&gt;登出&lt;/a&gt;&lt;/div&gt;;'; <br>
        } <br>
        {/dede:php}</div>
<br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>ajax方法:</span>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
         </p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        小提示,除了利用此方法之外我们还可以使用ajax来操作了,这种方法比上面还要简单一些,如我们把下面代码保存成ajax.php,代码如下:<br>
         </p>
<div class="msgheader" style='margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; font-family: tahoma, arial, "Microsoft YaHei";'>
        <div class="right">
                <span><u>复制代码</u></span>
</div>
        代码如下:</div>
<div class="msgborder" id="phpcode10" style='margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; font-family: tahoma, arial, "Microsoft YaHei";'>
        &lt;?php<br>
        require_once(DEDEMEMBER."/config.php"); <br>
        $uid = $cfg_ml-&gt;M_LoginID; <br>
        if(!$uid){ <br>
        echo '&lt;div&gt;&lt;a class="login-button" href="login.php"&gt;登录&lt;/a&gt; |&lt;a class="join-button" href="add.php"&gt;加入&lt;/a&gt;&lt;/div&gt;'; <br>
        }else{ <br>
        echo '&lt;div&gt; <br>
        &lt;a class="login-button" href="#"&gt;'.$uid.'&lt;/a&gt; |&lt;a class="join-button" href="&lt;?php echo $cfg_memberurl; ?&gt;/index_do.php?fmdo=login&amp;dopost=exit"&gt;登出&lt;/a&gt;&lt;/div&gt;;'; <br>
        } <br>
        ?&gt;</div>
<br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>然后在如首页中index.html中导入jquery的文件包,然后如下布局,登录框架状态地址我们写一个&lt;div id="loginajax"&gt;加载中...&lt;/div&gt;</span>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
         </p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        然后在页面底部加一个</p>
<div class="msgheader" style='margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; font-family: tahoma, arial, "Microsoft YaHei";'>
        <div class="right">
                <span><u>复制代码</u></span>
</div>
        代码如下:</div>
<div class="msgborder" id="phpcode11" style='margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; font-family: tahoma, arial, "Microsoft YaHei";'>
        $('loginajax').load('ajax.php');</div>
<span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>这样就解决了.</span>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
         </p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        希望本文所述对大家的dedecms建站有所帮助。</p>
頁: [1]
查看完整版本: 织梦dedecms页面获取会员状态的方法