Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

How to hide menu code in login page

Hi i am developing a website using phalcon. My homepage is divided into header index and footer. the header has menu bar which is common to all other pages but for the login page i dont want this menu bar. so how to hide this menu bar code only in the login page pls help me.

my menu bar code is

<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
          <ul class="nav navbar-nav main_menu">
            <li><?php echo Phalcon\Tag::linkTo(array('index', '<img src="images/home.png">'));?></li>
            <li><?php echo Phalcon\Tag::linkTo(array('my-sale', '<img src="images/mysale.png">'));?></li>
            <li><?php echo Phalcon\Tag::linkTo(array('customers', '<img src="images/customers.png">'));?></li>
            <li><?php echo Phalcon\Tag::linkTo(array('campaign', '<img src="images/campaign.png">'));?></li>
            <li><?php echo Phalcon\Tag::linkTo(array('analysis', '<img src="images/analysis.png">'));?></li>
            <li><?php echo Phalcon\Tag::linkTo(array('myaccount', '<img src="images/myaccount.png">'));?></li>
          </ul>
        </div>

How to hide this code in login page ?



473

You can check controller , if is controler and action login or page then hide it



6.8k

In Volt it's simple action just override block with menu for login page. Multiple Inheritance

Hi, thank you for the response. Iam a beginner in phalcon, can you please show me with an example pls.



33.0k
Accepted
answer

Hey man

We have two solution for problem of you.

Case1: We have assume url login is /login/username to login is contoller

    {% if this.view.getControllerName() == 'login'%}
        //do hide code
    {%else%}
      //do display code
    {%endif%}

Case 2: If you set session for user as login:

    {% if ! this.get.seesion('auth') %}
        //do hide code
    {%else%}
      //do display code
    {%endif%}

Solved the problem.....Thanks man...



6.8k

Hi, thank you for the response. Iam a beginner in phalcon, can you please show me with an example pls.

it very simple I assume that you use volt.

Than you easily can do next

<?php

class IndexController extends Controller
{
    public function indexAction()
    {
        //Action for index 
        //Also it has layout views/index/index.volt
    }

    public function loginAction()
    {
        //Action for index 
        //Also it has layout views/index/login.volt
    }
}

views/layout.volt

<html>
<title></title>
<head></head>
<body>
    <div id="main-menu">
        {% block menu %}
            <ul>
                <li>Item1</li>
                <li>Item2</li>
            </ul>
        {% endblock %}
    </div>
    <div class="container">
        {% block content %}{% endblock %}
    </div>
</body>
</html>

views/index/login.volt

{% extends "layout.volt" %}
{% block menu %}
            <ul>
                <li>Item1FromLoginpage</li>
                <li>Item1FromLoginpage</li>
            </ul>
{% endblock %}

Was that clear for you? In this case you do not need additional condition for check controllerName. What if you will need one more menu?