v2.5.2
Giriş yap

Tayfun abi udemy php kurs proje admin sidbar submenu problem

gangboy
430 defa görüntülendi

simdi tayfun abi projesinde submenu kullandi ama benim projemde dropdown kullandim bu asagidaki ornek tayfunabinin ornek

<?php
    <ul>
        <?php foreach ($menus as $mainUrl => $menu): if (!permission($menu['url'], 'show')) continue; ?>
            <li class="<?= (route(1) == $menu['url']) || ( isset($menu['submenu']) && array_search(route(1), array_column($menu['submenu'], 'url')) !== false) ? 'active' : null ?>">
                <a href="<?= admin_url($menu['url']) ?>">
                    <span class="fa fa-<?= $menu['icon'] ?>"></span>
                    <span class="title">
                        <?= $menu['title'] ?>
                    </span>
                </a>
                <?php if (isset($menu['submenu'])): ?>
                    <ul class="sub-menu">
                        <?php foreach ($menu['submenu'] as $k => $submenu): if (!permission($submenu['url'], 'show')) continue; ?>
                            <li class="<?=route(1) == $submenu['url'] ? 'active' : null?>">
                                <a href="<?= admin_url($submenu['url']) ?>">
                                    <?= $submenu['title'] ?>
                                </a>
                            </li>
                        <?php endforeach; ?>
                    </ul>
                <?php endif; ?>
            </li>
        <?php endforeach; ?>
        <li class="line">
            <span></span>
        </li>
    </ul>
?>

submenularida bu sekilde yaziyor

 <?php
 [
        'url' => 'posts',
        'title' => 'Blog',
        'icon' => 'rss',
        'permissions' => [
            'show' => 'Görüntüleme',
            'add' => 'Ekleme',
            'edit' => 'Düzenleme',
            'delete' => 'Silme'
        ],
        'submenu' => [
            [
                'url' => 'posts',
                'title' => 'Konular'
            ],
            [
                'url' => 'tags',
                'title' => 'Etiketler',
                'permissions' => [
                    'show' => 'Görüntüleme',
                    'add' => 'Ekleme',
                    'edit' => 'Düzenleme',
                    'delete' => 'Silme'
                ]
            ],
        ]
    ],
 ?>

simdi benim yazidim kodlari gelsek soyle

 <?php
 <ul class="navbar-nav flex-fill w-100 mb-2">
                <?php foreach ($menus as $mainUrl => $menu): if (!permission($menu['url'], 'show')) continue; ?>
                    <!--<li class="nav-item dropdown">-->
                    <li class="nav-item <?= (route(1) == $menu['url']) || (isset($menu['dropdown']) && array_search(route(1), array_column($menu['dropdown'], 'url')) !== false) ? 'active' : null ?>">
                        <a href="<?= admin_url($menu['url']) ?>"
                           class="nav-link">
                            <i class="fe fe-<?= $menu['icon'] ?> fe-16"></i>
                            <span class="ml-3 item-text"><?= $menu['title'] ?></span>
                        </a>
                        <?php if (isset($menu['submenu'])): ?>
                            <ul class="collapse list-unstyled pl-4 w-100">
                                <?php foreach ($menu['dropdown'] as $k => $submenu): if (!permission($submenu['url'], 'show')) continue; ?>
                                    <!--- <li class="nav-item active">-->
                                    <li class="nav-item<?= route(1) == $submenu['url'] ? 'active' : null ?>">
                                        <a class="nav-link pl-3" href="<?= admin_url($submenu['url']) ?>"><span
                                                    class="ml-1 item-text"><?= $submenu['title'] ?></span></a>
                                    </li>
                                <?php endforeach; ?>
                            </ul>
                        <?php endif; ?>
                    </li>
                <?php endforeach; ?>
            </ul>
 ?>

ve dropdown kodlarim boyle

<?php
[
        'url' => 'pagess',
        'title' => 'Sayfalar',
        'icon' => 'file',
        'permissions' => [
            'show' => 'Görüntüleme',
            'edit' => 'Düzenleme',
            'delete' => 'Silme'
        ],

        'dropdown' => [
            [
                'url' => 'add-page',
                'title' => 'Sayfa Ekle',
                'permissions' => [
                    'show' => 'Görüntüleme'
                ]
            ],

        ]

    ],
?>

benim dropdownlari listenemiyor

Yardimci olursaniz cok sevenerim belki cog kisi bu hata ile karsalabilir Tesekkurler

Cevap yaz
Cevaplar (0)
Henüz kimse cevap yazmadı. İlk cevap yazan sen ol!