How can I remove these views?

I am using the basic template, but those views that are inside the red box are from the frontend but still appears in the backend and what I want is to remove it only in the backend.
Is there any way to do it?

These aren’t part of the template but part of your project. We can’t help with it.

An application created by app-basic template should have those navigation buttons defined in views\layouts\main.php. I’m sure you know it and have already customized them to your needs.

So what you want to do is to dynamically add/remove some buttons to/from the nav bar according to your conditions. Probably you could do it by checking the access rights of the current user.

1 Like

I have already made the controls that the user and the administrator can see but the About Us, Contact Us buttons appear both in the backend and in the user and I do not want them to appear.
This is how I have defined my main

this is how the buttons with the information appear in the manager

As you have already done for “producto” and others, you could do something like the following for the “Contact Us” button.

(is not admin) ? (Contact us button) : ("")

(is not admin) should be replaced by something like (Yii::$app->user->isGuest) or (!Yii::$app->user->can('admin')). It depends on how you organize the user rights.

BTW, please show us your code using code tag and text where applicable, rather than using screen shots.

this is code main.php
echo Nav::widget([
‘options’ => [‘class’ => ‘navbar-nav’],
‘items’ => [
[‘label’ => ‘Inicio’, ‘url’ => [’/site/index’]],

        ['label' => 'Productos', 'url' => ['/producto/index']])

        ['label' => 'Tiendas', 'url' => ['/tienda/index']])

        ['label' => 'Categorias', 'url' => ['/categoria/index']])

        ['label' => 'Carrusel', 'url' => ['/carousel/index']])

        ['label' => 'Nosotros', 'url' => ['/site/about']],

        ['label' => 'Productos', 'url' => ['/producto/lista']],

        ['label' => 'Contáctanos', 'url' => ['/site/contact']],

        Yii::$app->user->isGuest ? (

            ['label' => 'Iniciar sesion', 'url' => ['/site/login']]
        ) : (
            . Html::beginForm(['/site/logout'], 'post', ['class' => 'form-inline'])
            . Html::submitButton(
                'Logout (' . Yii::$app->user->identity->username . ')',
                ['class' => 'btn btn-link logout']
            . Html::endForm()
            . '</li>'

So, something like this:

    (is not backend) ? (
    ['label' => 'Nosotros', 'url' => ['/site/about']])
    : (""),

I can’t tell what to replace (is not backend), because I don’t know how you control access rights of the users. It depends on you.

I use the accesControl

How many kinds of users do you need?

  • 2 kinds … guest and registered user
  • 3 kinds … guest, registered user and admin user

Or, in other words, how do you distinguish frontend and backend?