I want to use a file called header.php which includes a bootstrap navbar header, is it possible to change for example the 'active' tab in the menu dynamically according to the specific page I am on?
Header.php file:
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="container-fluid">
<div class="navbar-header">
Example Website
</div>
<ul class="nav navbar-nav">
<li class="active" id="page1">Page 1</li>
<li id="page2">Page 2</li>
<li id="page3">Page 3</li>
</ul>
</div>
</div>
Let's say I include this with php into page1.php, page2.php and page3.php,
How can I dynamically change the active tab from header.php to for example Page 2 in case of being on page 2?
Update:
I found a solution. Thanks to one of the 'duplicate' references.
Related
I am using current wordpress version, my goal is to active the navbar of the current page using php.
I have this current php code in my navbar:
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav navbar-right main-nav">
<li>
top
</li>
<li>
FIRST PAGE
</li>
<li>
SECOND PAGE
</li>
</ul><!--/.nav-->
</div><!-- /.navbar-collapse -->
I wanted to put additional active class when the current page is open.
I have a problem with main navigation menu in Magento 1.9:
<nav class="navbar" role="navigation"> <div class="container">
<ul class="nav navbar-nav">
<li class="dropdown">AAA<b class="caret"></b>
<ul class="dropdown-menu"><li class="title">AAB
<li class="" data-submenu-id="submenu-category-node-13550"><a href="#" class=" has-submenu" >AAE</a>
<div id="submenu-category-node-13550" class="popover">
<h2>CHANGE TAG! </h2>
<ul> <li class=""><a href="...
I would like to change the tag H2 inside the submenu, in an H3 tag or other tag, but I don't know where I can find the code; I try to search in app/code/core/Mage/Catolg/Block/Navigation.php and also in efault\template\page\html\header.phtml but without success...
Can anyone helps me? Thanks!
The code shows that this is not exactly the standard menu of the Magento, so look in these folders
app\code\community\
app\code\local\
you may have a module like MegaMenu installed. Therefore, you need to search the file in the module.
I had some big problems calling my header at all from project1.php. It got solved with the header included like this:
<?php include $_SERVER['DOCUMENT_ROOT'] . '/vouzalis/resources/includes/header.php'; ?>
The header is now called, but all my CSS is not called. Howcome can that be? On all my pages there is lying in the root folder the CSS is working fine.
My folder structure is looking like this:
This code below is a snip of my header. As you can see Home should go to index.php. But when I am in my project1.php and I click on Home I get the URL: `
http://localhost:8888/vouzalis/projects/index.php
The correct root should be:
http://localhost:8888/vouzalis/index.php
It does not make sense to be. Does anybody have a clue why? Is it something with how the header is included?
<div class="navbar-collapse collapse">
<ul class="nav nav-pills nav-main pull-right">
<!-- begin navigation items -->
<li class="active">Home</li>
<li>
Services
</li>
<li>
Portfolio
</li>
<li>
About Me
</li>
<li>Contact</li>
<!-- end navigation items -->
</ul>
</div>
I believe the problem is here:
<li class="active">Home</li>
Replace href="index.php" with href="/vouzalis/index.php". The / specifies the domain root, without it, the root is the your current location (/vouzalis/projects/).
My colleague and I are working on a WordPress-Plugin that generated posts using a custom post type. It all work's fine until You look at the posts. The generated pages look good and use the Themes single.php template. The only problem is, that the menu, that works on all other pages of the site is empty on the pages generated by the plugin.
By empty I mean that the structure including links is there, just the text inside the <a> tags.
The generated menu on a post generated by the plugin looks like this
<nav id="primary-navigation" class="site-navigation primary-navigation" role="navigation">
<div class="nav-menu">
<ul>
<li class="page_item page-item-1763">
</li>
<li class="page_item page-item-1761">
</li>
[...]
</ul>
</div>
</nav>
For all other pages, the menu looks like this:
<nav id="primary-navigation" class="site-navigation primary-navigation" role="navigation">
<div class="nav-menu">
<ul>
<li class="page_item page-item-1763">
About
</li>
<li class="page_item page-item-1761">
Galerie
</li>
[...]
</ul>
</div>
</nav>
As You can see, the only difference is that there is no text between the <a> and </a> tags, which makes the menu unusable.
We really have no idea of how the plugin / custom-post-type creates this issue, as we tried this with different themes, and they all behave the same - so it is not an issue with the theme.
Any comment or hint that points in the right direction is greatly appreciated.
I have a navbar with sublists. I use this navbar for a CSS navbar at the top of my web page, with links for the main pages and drop-down lists for the pages in the sub-lists. I would like to use the same structure to create a navbar at the side of my page for sublists.
All of my HTML pages have the following line near the top of the <BODY> that creates the navbar:
<?php include('navbar.php'); ?>
CSS styling of this navbar is taken care of elsewhere.
Suppose my navbar.php file has the following:
<nav id="mainnavbar>
<ul id="index">
<li>Home</li>
<li>Personal
<ul id="personal">
<li>About Me</li>
<li>Contact Info</li>
</ul>
</li>
<li>Professional
<ul id="professional">
<li>Activities</li>
<li>Resume</li>
</ul>
</li>
</ul>
</nav>
The horizontal navbar at the top of my page would list "Home | Personal | Professional", and there would be dropdown menus on "Personal" and "Professional". This navbar is easily included on ALL pages for a uniform experience. Not too hard.
If a user actually navigates to one of the main (or "parent") pages (e.g. "Home", "Personal", or "Professional"), however, I want there to be a second, vertical navbar on the side of that page with links to that page's "children."
For example, if the user goes to the "Personal" page, there should be a side-navbar with links to "About Me" and "Contact Info". If instead the user navigates to "Professional", that sidebar should instead display links to "Activities" and "Resume". If the user decides to go back to the "Home" page, the sidebar should display "Personal" and "Professional". (Although it would be 100% fine if it also displayed "Home" -- perhaps it would be easier that way?)
While I could hard-code a new <nav> for each page, I already have a unordered list structure and would like to make use of it. Any ideas how this could be done, or if there's a better way to do it?
Perhaps I would want to dynamically generate (via the magic of PHP) a second instance of <nav> that is a sort of partial copy of <nav id="mainnavbar">, listed above, but including one of the nested unordered lists, rather than everything. Then I could position and stylize each navbar separately.
(Note that only the Home, Personal and Professional pages should have a sidebar navigation menu because only they have "child" pages. The "child" pages should not have a sub-menu. )
In essence, I should have the following:
For index.html, I should have the following dynamically generated based on navbar.php:
<nav id="subnavbar">
<ul id="index">
<li>Home</li>
<li>Personal </li
<li>Professional</li>
</ul>
</nav>
For personal.html, I should have the following dynamically generated based on navbar.php:
<nav id="subnavbar">
<ul id="professional">
<li>Activities</li>
<li>Resume</li>
</ul>
</nav>
For professional.html, I should have the following dynamically generated based on navbar.php:
<nav id="subnavbar">
<ul id="professional">
<li>Activities</li>
<li>Resume</li>
</ul>
</nav>
For all other pages, there should be no sidebar navigation. (Or perhaps I should have some default navbar as a placeholder??)
I'm not sure if having the same id for an unordered list in two different <nav> sections would be problematic, however.
Thanks again for your help!
You can use PHP to determine what page you are on, and print out different HTML for the different pages. I put together the simplest version of what you are asking for. Use the same principle to expand on this. You can use the $_SERVER superglobal to find out the current URL.
<?php
// See if current URL ends with "personal.html"
$personal = preg_match('/personal\.html$/',$_SERVER['REQUEST_URI']);
?>
<nav>
<ul>
<li>Home</li>
<li>Personal
<?php if (!$personal) print '<ul>'; ?>
<li>About Me</li>
<li>Contact Info</li>
<?php if (!$personal) print '</ul>'; ?>
</li>
<li>Professional
<ul>
<li>Activities</li>
<li>Resume</li>
</ul>
</li>
</ul>
</nav>
All I am doing here is removing the <ul> tags for the personal page, which will put the two nested <li> inline with the rest of the navbar elements. You need to expand on this to fit the design you need.