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">
<a href="#" class="navbar-brand">Example Website</a>
</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.