I have following php code for horizontal menu, where I am calling the respective page from this php file, but I want whenever I call that page, that a href page become active.
<li class="mt">
<li class="sub-menu">
<a class="active" href="main.php">
<i class="fa fa-dashboard"></i>
<span>Dashboard</span>
</a>
<ul class="sub">
<li><a href='?url=profile/profile.php'><span>My Profile</span></a></li>
<li><a href='?url=profile/editprofile.php'><span>Edit my profile</span></a></li>
<li><a href='?url=profile/welcome-letter.php'><span>Welcome Letter</span></a></li>
<li class='last'><a href='?url=profile/change-password.php'><span>Change Password</span></a>
</li>
</ul>
</li>
</li>
<?php if ($epin_module == TRUE) { ?>
<li class="sub-menu">
<a href="javascript:;">
<i class="fa fa-cogs"></i>
<span>My e-PIN</span>
</a>
<ul class="sub">
<li ><a href='?url=epin/used.php'><span>Used e-Pin</span></a></li>
<li><a href='?url=epin/un-used.php'><span>Unused e-Pin</span></a></li>
<li><a href='?url=epin/request.php'><span>Request e-Pin</span></a></li>
<li><a href='?url=epin/transferreport.php'><span>E-PIN Transfer report</span></a></li>
<?php if ($autowithdraw == FALSE) { ?>
<li class='last'><a href='?url=epin/epingenerate.php'><span>E-PIN generate report</span></a>
</li>
<?php } ?>
</ul>
</li>
I want when the MY e-Pin page is visited, that page became active. currently if I visit that page main.php stays active always.
You can test url GET parameter for each links like that :
Where you have to replace both {MyUrl} by the real url value.
Related
Hi I am trying to get a dropdown list to appear when you click a button, problem is that whenever I click the button it goes to the index page instead of showing the list.
However, the button works only on one specific page which is almost identical to the others.
Here is the code:
<li class="dropdown">
<a id="dLabel" data-target="#" href="" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
<?Php echo $_SESSION['email']; ?><span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li>User Details</li>
<!-- <li>Another action</li>
<li>Something else here</li> -->
<li role="separator" class="divider"></li>
<li>Logout</li>
</ul>
</li>
Please use javascript:void(0) instead of blank.
<li class="dropdown">
<a id="dLabel" data-target="#" href="javascript:void(0)" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
<?Php echo $_SESSION['email']; ?><span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li>User Details</li>
<!-- <li>Another action</li>
<li>Something else here</li> -->
<li role="separator" class="divider"></li>
<li>Logout</li>
</ul>
I want to make a sidebar for my webpage but I am having some trouble doing it, I followed a lot of tutorial and yet the sidebar didn't come out instead only the words came out. Most people I saw just only use php but I feel like there is a need to use javascript. Can someone give me a template on making a sidebar something like this in the screenshot.
This is the codes that I used:
sidebar.blade.php
<div class="app-body">
<div class="sidebar">
<nav class="sidebar-nav">
<ul class="nav">
<li class="nav-item">
<a class="nav-link" href="main.html"><i class="icon-speedometer"></i> Dashboard <span class="badge badge-primary">NEW</span></a>
</li>
<li class="nav-title">
UI Elements
</li>
<li class="nav-item nav-dropdown">
<a class="nav-link nav-dropdown-toggle" href="#"><i class="icon-puzzle"></i> Components</a>
<ul class="nav-dropdown-items">
<li class="nav-item">
<a class="nav-link" href="components/buttons.html"><i class="icon-puzzle"></i> Buttons</a>
</li>
<li class="nav-item">
<a class="nav-link" href="components/social-buttons.html"><i class="icon-puzzle"></i> Social Buttons</a>
</li>
</ul>
</li>
<li class="nav-item nav-dropdown">
<a class="nav-link nav-dropdown-toggle" href="#"><i class="icon-star"></i> Icons</a>
<ul class="nav-dropdown-items">
<li class="nav-item">
<a class="nav-link" href="icons/font-awesome.html"><i class="icon-star"></i> Font Awesome <span class="badge badge-secondary">4.7</span></a>
</li>
</ul>
</li>
<li class="nav-item">
<a class="nav-link" href="widgets.html"><i class="icon-calculator"></i> Widgets <span class="badge badge-primary">NEW</span></a>
</li>
Extras
</li>
<li class="nav-item nav-dropdown">
<a class="nav-link nav-dropdown-toggle" href="#"><i class="icon-star"></i> Pages</a>
<ul class="nav-dropdown-items">
<li class="nav-item">
<a class="nav-link" href="views/pages/login.html" target="_top"><i class="icon-star"></i> Login</a>
</li>
<li class="nav-item">
<a class="nav-link" href="views/pages/register.html" target="_top"><i class="icon-star"></i> Register</a>
</li>
</ul>
</li>
</ul>
</nav>
<button class="sidebar-minimizer brand-minimizer" type="button"></button>
</div>
This is what I get:
Why not using any admin templates? https://colorlib.com/wp/free-bootstrap-admin-dashboard-templates/
I'm in the process on covering the navigation bar on all the pages to a global navigation with the PHP. I'm using PHP also to add a class and show the current page.
The challenge that I'm facing is the parent navigation selection. It's underlined when it's on the child page and the sub-nav is also selected. Such as I'm on the "History" page, child page to the "About Us" page. Both are underlined.
The challenge that I'm facing is when I move over to the next page, "Service Areas" or any of it's children, the "About Us" nav selection is still underline. I'm trying to use the || logic to prevent that from happening.
Below is the following code:
<li class="dropdown <?php if ($thisPage=='About Us'||'History'||'Mission Values'||'Process'||'Our People'||'Testimonials'||'Capstone Cares') echo 'active'; ?>">
Is there a way that I can deselect the parent nav when I'm under a different nav section?
Website is http://capstone.dgpehrson.com
Here is the rest of the code...
On individual pages I'm adding:
<?php $thisPage="About Us"; ?>
I'm changing the name according to the page.
Here is the Navigation code:
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li class="dropdown <?php if ($thisPage=='About Us' || 'History' || 'Mission Values' || 'Process' || 'Our People' || 'Testimonials' || 'Capstone Cares') echo 'active'; ?>">
About Us<span class="caret"></span> <!-- Alink extentions that's been removed: data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false" -->
<ul class="dropdown-menu">
<li <?php if ($thisPage=="History") echo "class=\"active\""; ?>>History</li>
<li <?php if ($thisPage=="Mission Values") echo "class=\"active\""; ?>>Mission & Values</li>
<li <?php if ($thisPage=="Process") echo "class=\"active\""; ?>>Process</li>
<li <?php if ($thisPage=="Our People") echo "class=\"active\""; ?>>Our People</li>
<li <?php if ($thisPage=="Testimonials") echo "class=\"active\""; ?>>Testimonials</li>
<li <?php if ($thisPage=="Capstone Cares") echo "class=\"active\""; ?>>Capstone Cares</li>
</ul>
</li>
<li class="dropdown <?php if ($thisPage=='Service Areas'||'Apartments'||'Capital'||'Development Services'||'Manufactured Housing'||'Complimentary') echo 'active'; ?>">
Service Areas<span class="caret"></span> <!-- Alink extentions that's been removed: data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false" -->
<ul class="dropdown-menu">
<li <?php if ($thisPage=="Apartments") echo "class=\"active\""; ?>>Apartments</li>
<li <?php if ($thisPage=="Capital") echo "class=\"active\""; ?>>Capital</li>
<li <?php if ($thisPage=="Development Services") echo "class=\"active\""; ?>>Developement Services</li>
<li <?php if ($thisPage=="Manufactured Housing") echo "class=\"active\""; ?>>Manufactured Housing</li>
<li <?php if ($thisPage=="Complimentary") echo "class=\"active\""; ?>>Complimentary Value Analysis</li>
</ul>
</li>
<li class="dropdown">
Offerings<span class="caret"></span> <!-- Alink extentions that's been removed: data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false" -->
<ul class="dropdown-menu">
<li>Apartment</li>
<li>Manufactured Housing</li>
<li>Multi-family Land</li>
</ul>
</li>
<li class="dropdown">
Market Reports<span class="caret"></span> <!-- Alink extentions that's been removed: data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false" -->
<ul class="dropdown-menu">
<li>Florida</li>
<li>Kentucky</li>
<li>North Carolina</li>
<li>South Carolina</li>
<li>Tennessee</li>
<li>Virginia</li>
</ul>
</li>
<li>News</li>
<li>Careers</li>
<li>Contact Us</li>
</ul>
You have to have the compare between each 'or'. The string is just evaluating to a true.
if ($thisPage=='About Us'||$thisPage=='History'||$thisPage=='Mission Values'||$thisPage=='Process'||$thisPage=='Our People'||$thisPage=='Testimonials'||$thisPage=='Capstone Cares') echo 'active';
Thank you for reading... I have a 2 layer of navigation. which sort the content by good, bad and comment count. if user clicks on good it will bring another nav which is sort the content by time. such as today, last one week, last one month.
I can add class='active' using $_SERVER['PHP_SELF'] but twitter bootsrap dropdown menu does not have simple class='active' it is complicated. I am not able to come up with a solution. should I use for? foreach? I don't know. please see the html command in the code. this is my code.
<ul class="nav nav-tabs">
<li <?php if (basename($_SERVER['PHP_SELF']) == '/?Top'): ?> class="active"<?php endif; ?>>Top Content</li>
<li <?php if (basename($_SERVER['PHP_SELF']) == '/?Bad'): ?> class="active"<?php endif; ?>>Bad Content</li>
<li <?php if (basename($_SERVER['PHP_SELF']) == '/?Comments'): ?> class="active"<?php endif; ?>>Most Commented</li>
<!-- It's confusing me when It comes here... because as you see active option is not li tag. it's bunch of html code and also any url bellow can ben any of those up -->
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#"><i class="icon-time"></i> Today <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="URL=week" />Last 1 Week</a></li>
<li><a href="URL=month" />Last 1 Month </a></li>
<li><a href="URL=all" />All</a></li>
</ul>
</li>
</ul>
html commend: It's confusing me when It comes here... because as you see active li is not li it's bunch of html code and also also any url below can be any of those up
You can use the "active" class for the outter li (the one has class "dropdown") and another "active" class in your child dropdown.
This is an example
<ul class="nav nav-tabs">
<li class="">Home</li>
<li>Help</li>
<li class="dropdown active">
Dropdown <b class="caret"></b>
<ul class="dropdown-menu">
<li>Action</li>
<li class="active">Another action</li>
<li>Something else here</li>
<li class="divider"></li>
<li>Separated link</li>
</ul>
</li>
</ul>
A live demo in JSBin
I'm trying to build a basic header drop down nav for my three user account types, but they have different options depending on the account type. My code is throwing errors. Code is as follows:
<div class="btn-group pull-right">
<?php if ($this->logged_in):
$is_a = ($this->logged_in_usertype == App_Model_Users::TYPE_A);
$is_b = ($this->logged_in_usertype == App_Model_Users::TYPE_B);
$is_c = ($this->logged_in_usertype == App_Model_Users::TYPE_C);
?>
<a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
<i class="icon-user"></i> <?php echo $this->logged_in_nickname;?>
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<?php if ($is_b):?>
<li>Page Option One</li>
<li class="divider"></li>
<li>Page Option Two</li>
<li class="divider"></li>
<li>Page Option 3</li>
<li class="divider"></li>
<li>Page Option 4</li>
<li class="divider"></li>
<?php if ($is_a):?>
<li>Account-type 2 Profile</li>
<?php endif;?>
<?php endif;?>
<li>Account Settings</li>
<li class="divider"></li>
<li>Sign Out</li>
</ul>
<?php else:?>
<a class="btn" href="/login">
<i class="icon-user"></i> Register / Login
</a>
<?php endif;?>
</div>
I think my problem is the 2nd if statement for (if is_a)... but I'm not sure - I'm rather new to php. Could someone please help me with the correct way to construct this if statement w/ as little changes as possible to the code?
Can you post the actual error here, to inspect.
and you have a syntax error on line 32
<?php else:?>
And the second if is inside the fist if statment