I have menu which is has sub menus.
<li>
<i class="fa fa-flag-checkered" aria-hidden="true"></i> <span>Lead</span> <i class="icon-submenu lnr lnr-chevron-left"></i>
<div id="lead" class="collapse ">
<ul class="nav">
<li><i class="fa fa-quote-right" aria-hidden="true"></i><span> Quotation </span><i class="icon-submenu lnr lnr-chevron-left"></i>
<div id="quotation" class="collapse ">
<ul class="nav">
<li><i class="fa fa-dot-circle-o" aria-hidden="true"></i> Create Quotation</li>
<li><i class="fa fa-dot-circle-o" aria-hidden="true"></i> Quotation Summary</li>
<li><i class="fa fa-dot-circle-o" aria-hidden="true"></i> Send Quotation</li>
</ul>
</div>
</li>
</ul>
</div>
</li>
When I clicked it, I can not go directly to the page. I have to right-clicked on it to go to the desired page.
Here's an example of my controller
public function cquotation(){
$data = $this->salesModel->showCustomer();
$this->load->view('v_navbar');
$this->load->view('v_leftside');
$this->load->view('v_cquotation',array('data'=>$data));
}
Do you guys have any idea what's wrong with it?
I'm totally confused
Why are you using data-toggle="collapse" class="collapsed" on every hyperlink?. your code has data-toggle="collapse" class="collapsed" in every hyperlink.Bootstrap will prevent the default click event of a href .So remove every data-toggle="collapse" class="collapsed" part of a href in your code and it will work.
<li>
<i class="fa fa-flag-checkered" aria-hidden="true"></i> <span>Lead</span> <i class="icon-submenu lnr lnr-chevron-left"></i>
<div id="lead" class="collapse ">
<ul class="nav">
<li><i class="fa fa-quote-right" aria-hidden="true"></i><span> Quotation </span><i class="icon-submenu lnr lnr-chevron-left"></i>
<div id="quotation" class="collapse ">
<ul class="nav">
<li></i> Create Quotation</li>
<li></i> Quotation Summary</li>
<li></i> Send Quotation</li>
</ul>
</div>
</li>
</ul>
</div>
</li>
Related
I'm trying to 'include' a php file in a html template when a nav-item is selectd. The code below make active the item on click it. What I want to do is, at the same time it becomes active,load the php file with de same name than '$this' value is. I mean:
on click in tab 'two' ($this value), load in div '#contFl' the php file named 'two.php' at time its become 'active'; load 'one.php' on click in 'one' item;...
Tried a few ways of text estructure in 'load(...)' -last one on last code line- with no results. Pleasefull to have some help.
<script type="text/javascript">
$(document).ready(function(){
$("ul.navbar-nav > li").click(function(e){
$("ul.navbar-nav > li").removeClass("active");
$(this).addClass("active");
$("#contFl").load('"'+$(this).val()+'.php');
});
})
HTML code of navbar
<div id="collapsibleNavbar" class="collapse navbar-collapse justify-content-around">
<ul id="collUl" class="navbar-nav col-12 col-lg-auto me-lg-auto mb-1 mb-md-0">
<li class="nav-item nav-link active" id="uno" role="button"><i class="fa fa-home" aria-hidden="true"></i> Inicio</li>
<li class="nav-item nav-link" id="dos" role="button"><i class="fa fa-envelope" aria-hidden="true"></i> Dos</li>
<li class="nav-item dropdown" id="tres"><a class="nav-link dropdown-toggle px-2" href="#" role="button" data-bs-toggle="dropdown"><i class="fa fa-list" aria-hidden="true"></i> Tres</a>
<ul class="dropdown-menu">
<a class="dropdown-item" href="index.php"><i class="fa fa-home" aria-hidden="true"></i> Inicio</a>
<a class="dropdown-item" href="tres.php"><i class="fa fa-list" aria-hidden="true"></i> Tres</a>
<a class="dropdown-item" href="dos.php"><i class="fa fa-envelope" aria-hidden="true"></i> Dos</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="cuatro.php"><i class="fa fa-user" aria-hidden="true"></i> Cuatro</a>
</ul>
</li>
<li class="nav-item nav-link" id="cuatro" role="button"><i class="fa fa-user" aria-hidden="true"></i> Cuatro</li>
</ul>
Code in template where include new php file.
<?php
include(ASSETS."/navbar.php");
include(ASSETS."/banner.php")?>
<div id="contFl" class="container-fluid">
<!-- HERE THE NEW 'INCLUDE' -->
</div>
I want to add a dropdown menu to one of my menus in the nav-bar but I can’t seem to do it. I dont know where to put the dropdown code to make it function and with the CSS included.
Here’s my header.inc.php code:
<header class="flex-shrink-0 flex-grow-0">
<!-- Navigation Bar -->
<nav class="navbar navbar-expand-lg navbar-dark bg-ewarz sticky-top h-100 p-0">
<section class="container-fluid">
<!-- Nav Brand Text -->
<a class="navbar-brand d-none d-lg-block" style="font-size: 24pt; -moz-user-select: none; -webkit-user-select: none; -ms-user-select:none; user-select:none; -o-user-select:none;" href="#">e<span style="color: #aa3232">W</span>arz</a>
<!-- Burgermenu Toggler -->
<button class="navbar-toggler ml-auto mr-2 collapsed" style="margin: 15px;" data-toggle="collapse" data-target="#navMenu" aria-expanded="false">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse bg-ewarz" id="navMenu">
<!-- Nav Links -->
<ul class="navbar-nav mx-auto">
<li class="nav-item mx-3">
<a class="nav-link" href="/"><i class="mdi mdi-home mr-2"></i>Home</a>
</li>
<li class="nav-item mx-3">
<a class="nav-link" href="#"><i class="mdi mdi-server mr-2"></i>Servers</a>
</li>
<li class="nav-item mx-3">
<a class="nav-link" href="#"><i class="mdi mdi-account-multiple mr-2"></i>Crew</a>
</li>
<li class="nav-item mx-3">
<a class="nav-link" href="#"><i class="mdi mdi-cart mr-2"></i>Shop</a>
</li>
<li class="nav-item mx-3">
<a class="nav-link" href="#"><i class="mdi mdi-text-box-outline mr-2"></i>General<i class="mdi mdi-menu-down"></i></a>
</li>
<li class="nav-item mx-3">
<a class="nav-link" href="#"><i class="mdi mdi-information-outline mr-2"></i>About<i class="mdi mdi-menu-down"></i></a>
</li>
</ul>
</div>
<!-- Nav Icons -->
<section class="d-none d-lg-block d-lg-inline-flex">
<i class="icon mdi mdi-discord d-block mr-1"></i>
<i class="icon mdi mdi-steam d-block ml-1"></i>
</section>
</section>
</nav>
</header>
You can add again <ul><li> after <ul><li>.
You can use this for dropdown;
<ul class="navbar-nav mx-auto">
<li class="nav-item mx-3">
<a class="nav-link" href="/"><i class="mdi mdi-home mr-2"></i>Home</a>
<ul class="navbar-nav mx-auto">
<li class="nav-item mx-3">
<a class="nav-link" href="/"><i class="mdi mdi-home mr-2"></i>Home2</a>
</li>
<li class="nav-item mx-3">
<a class="nav-link" href="/"><i class="mdi mdi-home mr-2"></i>Home3</a>
</li>
<li class="nav-item mx-3">
<a class="nav-link" href="/"><i class="mdi mdi-home mr-2"></i>Home4</a>
</li>
</ul>
</li>
</ul>
Drop down menus in Navbar should be defined in this way.
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdownMenuLink" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Dropdown Heading
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
<a class="dropdown-item" href="#">Dropdown Item 1</a>
<a class="dropdown-item" href="#">Dropdown Item 2</a>
<a class="dropdown-item" href="#">Dropdown Item 3</a>
</div>
</li>
Sample code shown below:
<!-- Nav Links -->
<ul class="navbar-nav mx-auto">
<li class="nav-item mx-3">
<a class="nav-link" href="/"><i class="mdi mdi-home mr-2"></i>Home</a>
</li>
<li class="nav-item mx-3">
<a class="nav-link" href="#"><i class="mdi mdi-server mr-2"></i>Servers</a>
</li>
<!-- Add this block -->
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Dropdown Menu Text
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="#">Dropdown Item 1</a>
<a class="dropdown-item" href="#">Dropdown Item 2</a>
</div>
</li>
<!-- Add this block -->
</ul>
Refer this link for details
I am creating a website using Smarty and PDO, here is my header file and I'm not sure how I can make it change depending on whether a user is logged in or not?
When the user isn't logged in these options should appear (Friday, Saturday, Sunday, Sign up, Log in)
But when they sign in I want 'Sign up' and 'log in' to change to 'My account' and 'Sign Out'. Below are is the code I currently have.
//If user is logged in
<div id="navigation"> <ul class="nav" id="navigation">
<nav class="navbar navbar-expand-lg">
<button class="navbar-toggler" id="hideshow" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"><i class="far fa-caret-square-down"></i></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item">
<a class="nav-link" href="index.php?p=main">Home <i class="far fa-arrow-alt-circle-right"></i><span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="index.php?p=friday">Friday <i class="far fa-arrow-alt-circle-right"></i></a>
</li>
<li class="nav-item">
<a class="nav-link" href="index.php?p=saturday">Saturday <i class="far fa-arrow-alt-circle-right"></i></a>
</li>
<li class="nav-item">
<a class="nav-link" href="index.php?p=sunday">Sunday <i class="far fa-arrow-alt-circle-right"></i></a>
</li>
<li class="nav-item">
<a class="nav-link" href="index.php?p=logout" id="Logout" />Logout <i class="fas fa-sign-out-alt"></i></a>
</li>
<li class="nav-item">
<a class="nav-link" href="index.php?p=account">My account <i class="far fa-arrow-alt-circle-right"></i></a>
</li>
//If user isn't signed in
<div id="navigation"> <ul class="nav" id="navigation">
<nav class="navbar navbar-expand-lg ">
<button class="navbar-toggler" id="hideshow" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"><i class="far fa-caret-square-down"></i></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item">
<a class="nav-link" href="index.php?p=main">Home <i class="far fa-arrow-alt-circle-right"></i><span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="index.php?p=friday">Friday <i class="far fa-arrow-alt-circle-right"></i></a>
</li>
<li class="nav-item">
<a class="nav-link" href="index.php?p=saturday">Saturday <i class="far fa-arrow-alt-circle-right"></i></a>
</li>
<li class="nav-item">
<a class="nav-link" href="index.php?p=sunday">Sunday <i class="far fa-arrow-alt-circle-right"></i></a>
</li>
<li class="nav-item">
<a class="nav-link" href="index.php?p=signup" id="signup" />Signup <i class="fas fa-user-plus"></i></a>
</li>
<li class="nav-item">
</i>
</li></ul>
{/if}
</div>
</nav></div>
First of all assign a variable from Controller to your view, example:
$view->assign('USER_ID', $this->auth->getUserId());
then in template:
{if $USER_ID > 0}
{* html or template when user is logged in *}
{* if differences are big, better is create new sub-template: *}
{include file='./header-logged-in.tpl'}
{else}
{* html or template when user is not logged in *}
{include file='./header-logged-out.tpl'}
{/if}
if(isset($_SESSION['user_id'])) {
// User Logged In Navigation
} else {
// User Logged Out Navigation
}
Of course, you didn't provide enough information, this assumes your user session is set to $_SESSION['user_id'] <-- change to whatever your session is saved as.
I have the following html sidebar menu:
<li {{{ (Request::is('bookings/*') }}} data-toggle="collapse" data-target="#bookings">
<i class="fa fa-address-book" aria-hidden="true"></i> Bookings <i class="fa fa-chevron-down" aria-hidden="true"></i>
</li>
<ul class="sub-menu collapse" id="bookings">
<li class="collapsed">All Bookings</li>
<li class="collapsed" >Add New</li>
</ul>
<li {{{ (Request::is('bookings/*') || Request::is('bookings') ? 'class=active' : '') }}} data-toggle="collapse" data-target="#item2">
<i class="fa fa-address-book" aria-hidden="true"></i> Item 2 <i class="fa fa-chevron-down" aria-hidden="true"></i>
</li>
<ul class="sub-menu collapse" id="item2">
<li {{{ (Request::is('bookings') ? 'class=active' : 'collapsed') }}}>All Bookings</li>
<li {{{ (Request::is('bookings/create') ? 'class=active' : 'collapsed') }}} >Add New</li>
</ul>
This is a basic Bootstrap collapse menu that contains a sub menu which expands when the li element is clicked.
The problem I have is lets say I have 2 or 3 of these menu items that all have sub menus. There is a possibility that all of them could open at the same time, I don't like this because this forces a scroll overflow as the height increases which then shows a scrollbar for the side menu.
Is there a way I can prevent multiple elements from being expanded in Bootstrap?
I am using Laravel 5 if that helps.
I think this should help you, just play a little with it to adapt it to your needs:
<div class="row">
<div class="col">
<ul class="nav nav-stacked" id="accordion1">
<li class="panel"> <a data-toggle="collapse" data-parent="#accordion1" href="#firstLink">Test12</a>
<ul id="firstLink" class="collapse">
<li>SubTest1</li>
<li>SubTest1</li>
<li>SubTest1</li>
</ul>
</li>
<li class="panel"> <a data-toggle="collapse" data-parent="#accordion1" href="#secondLink">Test2</a>
<ul id="secondLink" class="collapse">
<li>SubTest2</li>
<li>SubTest2</li>
<li>SubTest2</li>
<li>SubTest2</li>
</ul>
</li>
</ul>
</div>
</div>
See it here
https://codepen.io/anon/pen/ZaMOxN
I have directory like this "localhost/site/folder1/file.php", I need to access file.php from "site" directory this way
href = "folder1/file.php"
unfortunately it takes me to
href = "folder1/folder1/file.php"
and when I access "index.php" file located in "site" directory from "folder1", this way
href = "../index.php"
it takes me to root directory in c: I mean this way
href = "localhost/index.php".
I have stacked with this problem for two days now, please any one to help me get out this.
Note: I am using bootstrap framework
More edit...
here is the full code.
<section>
<section class="hbox stretch">
<!-- .aside -->
<aside class="bg-black dk nav-xs aside hidden-print" id="nav">
<section class="vbox">
<section class="w-f-md scrollable">
<div class="slim-scroll" data-height="auto" data-disable-fade-out="true" data-distance="0" data-size="10px" data-railOpacity="0.2">
<!-- nav -->
<nav class="nav-primary hidden-xs">
<ul class="nav bg clearfix" data-ride="collapse">
<!--<li class="hidden-nav-xs padder m-t m-b-sm text-xs text-muted">
Discover
</li>-->
<li>
<a href= "../index.php">
<i class="icon-home icon text-success"></i>
<span class="font-bold">Home</span>
</a>
</li>
<li>
<a href="#" class="auto">
<span class="pull-right text-muted">
<i class="fa fa-angle-left text"></i>
<i class="fa fa-angle-down text-active"></i>
</span>
<i class="icon-music-tone-alt icon text-info"></i>
<span class="font-bold">Audios</span>
</a>
<ul class="nav dk text-sm">
<li >
<a href="../general.php" class="auto">
<i class="fa fa-angle-right text-xs"></i>
<span>Speaches</span>
</a>
</li>
<li >
<a href="../general.php" class="auto">
<i class="fa fa-angle-right text-xs"></i>
<span>Preaches</span>
</a>
</li>
<li >
<a href="../general.php" class="auto">
<i class="fa fa-angle-right text-xs"></i>
<span>Interviews</span>
</a>
</li>
<li >
<a href="../general.php" class="auto">
<i class="fa fa-angle-right text-xs"></i>
<span>Songs</span>
</a>
</li>
</ul>
</li>
<li>
<a href="#" class="auto">
<span class="pull-right text-muted">
<i class="fa fa-angle-left text"></i>
<i class="fa fa-angle-down text-active"></i>
</span>
<i class="icon-book-open icon text-primary-lter"></i>
<span class="font-bold">Writtings</span>
</a>
<ul class="nav dk text-sm">
<li >
<a href="../general.php" class="auto">
<i class="fa fa-angle-right text-xs"></i>
<span>Books</span>
</a>
</li>
<li >
<a href="../general.php" class="auto">
<i class="fa fa-angle-right text-xs"></i>
<span>Jounals</span>
</a>
</li>
</ul>
</li>
<li>
<a href="#">
<i class="icon-users icon text-primary-lter"></i>
<span class="font-bold">Artists</span>
</a>
</li>
<li>
<a href="#">
<i class="icon-film icon text-info-dker"></i>
<span class="font-bold">Albums</span>
</a>
</li>
<li class="m-b hidden-nav-xs"></li>
</ul>
<ul class="nav" data-ride="collapse">
<li class="hidden-nav-xs padder m-t m-b-sm text-xs text-muted">
User Account
</li>
<li>
<?php
if(!isset ($_SESSION['email'])){
echo "
<a href='../signin.php' class='auto'>
<i class='icon-login icon'>
</i>
<span>Signin</span>
</a>
</li>
<li >
<a href='../signup.php' class='auto'>
<i class='fa fa-smile-o'>
</i>
<span>Signup</span>
</a>
</li>
";
}else{
echo "
<a href='../signout.php' class='auto'>
<i class='icon-logout icon'>
</i>
<span>SignOut</span>
</a>
</li>";
if (!isset($_SESSION['admin_name'])) {
echo "
<li >
<a href='profile.php' class='auto'>
<i class='fa fa-smile-o'>
</i>
<span>My profile</span>
</a>
</li>
";
}else{
echo "
<li >
<a href='MembersManagement.php' class='auto'>
<i class='fa fa-edit'>
</i>
<span>Manage Member</span>
</a>
</li>
<li >
<a href='admin.php' class='auto'>
<i class='fa fa-edit'>
</i>
<span>My Dashboard</span>
</a>
</li>
";
}
}
?>
</ul>
</nav>
<!-- / nav ---->
</div>
</section>
And the problem is on this line
<nav class="nav-primary hidden-xs">
When I remove "nav-primary" everything is doing fine with the anchors () but it changes the appearance and arrangements in the section, what should I do, I am new to bootstrap frameworks.
If you are having problem with relative urls, you can try doing with absolute urls like :
href = "localhost/site/folder1/file.php".
and for the other one you can do same:
href = "localhost/site/index.php
Maybe this helps.