【问题标题】:Show header menu by membership type in php在php中按会员类型显示标题菜单
【发布时间】:2020-04-07 03:05:57
【问题描述】:

我的脚本中有 4 种帐户类型。

类型为:用户、医生、乌兹曼、医院。我想要做的是普通用户只能在标题菜单上看到几个链接,而医生、乌兹曼和医院用户可以看到更多链接。对不起我的英语不好。

这样的代码:

    <nav id="menu">
            <a href="" style="background-image: url(static/img/logo.png)"></a>
            <ul>


                <?php if ($this->user->logged()): ?>
                <li>
                    <a href="giris-yap"></i> Hesabım</a>
                    <ul>
                        <li ><a href="hesabim" >Profil Sayfası</a></li>
                        <li ><a href="hesabim/duzenle" >Profil Düzenle</a></li>
                        <li ><a href="hesabim/fotograf-duzenle" >Fotoğraf</a></li>
                        <li ><a href="hesabim/sifre-guncelle" >Şifre İşlemleri</a></li>
                        <li ><a href="hesabim/hizmetler" >Hizmetler</a></li>
                        <li ><a href="hesabim/sosyal-medya" >Sosyal Ağ</a></li>
                        <li ><a href="hesabim/makaleler" >Makaleler</a></li>
                        <li ><a href="hesabim/videolar" >Videolar</a></li>
                        <li ><a href="hesabim/sorular" >Sorular</a></li>
                        <li ><a href="hesabim/randevular" >Randevu Talepleri</a></li>
                    </ul>
                    <li ><a href="cikis" ><i class="fa fa-sign-out"></i> ÇIKIŞ YAP</a></li
                </li>
                <?php else: ?>

                <li>
                    <a href="giris-yap">Giriş Yap</a>
                </li>
                <li>
                    <a href="uye-ol">Üye Ol</a>
                </li>
                <li ><a href="uye-ol/doktor" style="color: rgba(0,0,0,.5) !important">Doktor musunuz?</a>
            </li>

        </ul>
    </nav>

我想做的是:普通用户只会看到前 3 个链接,而其他帐户类型会看到全部。

你能帮我解决这个问题吗?

【问题讨论】:

  • 显示你的 $this->session->set_userdata() 你如何在 session 中存储类型

标签: php html codeigniter


【解决方案1】:

您可以为此使用会话。 在登录功能的控制器中,您可以像这样在会话中添加用户类型:

$this->session->set_userdata('type', 'doctor');

那么在您看来,您可以像这样检查它:

$type = $this->session->userdata('type');
if ($type === 'doctor) {
    //nav menu for doctor
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-11
    • 1970-01-01
    相关资源
    最近更新 更多