0

I want to what is better way of doing this.Suppose user visit a website he is not yet registered on our website so nav bar shows some options like sign up ,login, help these are options before registration now if user registrated for website after login options on nav bar changes as my profile,account settings,home etc . So how this is done do we have to create two seprate nav bar before and after login or there is another way. after much thinking i have done this

<?php if(!$this->session->userdata('is_login')) : ?>
    <div class="collapse navbar-collapse navbar-ex1-collapse">
      <ul class="nav navbar-nav navbar-right">
        <li><a href="#login-modal"id='modal-launcher' data-toggle="modal">Login</a></li>
        <li><a href="<?php echo base_url('Register/index') ?>">Sign-Up</a></li>
        <li><a href="#">Help</a></li>
.....

<?php else : ?>
   home 
   my profile //code for displaying these 
   account settings etc 

   <?php endif; ?>

Is this is way we do or in any other way.

Edited by shany0786

3
Contributors
3
Replies
18
Views
2 Years
Discussion Span
Last Post by diafol
1

Most systems would create the menu by checking which elements should show. Typically that would entail checking if the user was logged in or not and displaing the log in/register stuff if the they weren't.
So, you wouldn't need to create a whole new menu, you just use the checks to determine which <li> elements get created.
But, essentially, you're on the right track.

0

Can you give some reference for doing it.Now problem i am facing is I have two account type which have different menus to display after login So how to do that.Any reference or further help?

1

What you want to avoid doing is having 2 separate navbar include files, so doing the if/else method makes more sense. Agree with hericles - you're on the right track.

An alternative method would be to store your nav info in a database and have a flag column against each item (e.g. 0, 1, 2 for all, guest only, registered only).

A quick example of this can be seen in my tutorial (on How to Store Menus and Submenus) - although you'd have to add the flag bit:

DW Tutorial: Common Issues with MySQL and PHP

Edited by diafol

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.