summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJack Mitchell <jack@embed.me.uk>2014-08-24 14:39:08 +0100
committerJack Mitchell <jack@embed.me.uk>2014-08-24 14:39:08 +0100
commit48abcc734ec954008982b4b40cef0271eaaae6be (patch)
tree5f937d17f4180eb475d26d21a4b002d181b0cbf2
parent6f1888a4d8ac66eefc8172aa7f6f07fd40cfc877 (diff)
downloadopenembedded-web-frontpages-48abcc734ec954008982b4b40cef0271eaaae6be.zip
openembedded-web-frontpages-48abcc734ec954008982b4b40cef0271eaaae6be.tar.gz
openembedded-web-frontpages-48abcc734ec954008982b4b40cef0271eaaae6be.tar.bz2
support for dynamic active button
-rw-r--r--includes/navbar.php24
1 files changed, 18 insertions, 6 deletions
diff --git a/includes/navbar.php b/includes/navbar.php
index d4d9133..e6132ae 100644
--- a/includes/navbar.php
+++ b/includes/navbar.php
@@ -1,3 +1,9 @@
+<?php
+ // Work out the button name from the file name
+ $current_page = basename($_SERVER['PHP_SELF']);
+ $button_name = explode(".", $current_page)[0];
+?>
+
<nav class="navbar navbar-default oe-blue" role="navigation">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
@@ -13,12 +19,12 @@
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
- <li name="home-button" class="active"><a href="#">Home</a></li>
- <li name="community-button"><a href="#">Community</a></li>
- <li name="faq-button"><a href="#">FAQ</a></li>
- <li name="download-button"><a href="#">Download</a></li>
- <li><a href="#">Wiki</a></li>
- <li name="documentation-button"><a href="#">Documentation</a></li>
+ <li name="index-button"><a href="index.php">Home</a></li>
+ <li name="community-button"><a href="community.php">Community</a></li>
+ <li name="faq-button"><a href="faq.php">FAQ</a></li>
+ <li name="download-button"><a href="download.php">Download</a></li>
+ <li name="wiki-button"><a href="http://openembedded.org/wiki/Main_Page">Wiki</a></li>
+ <li name="documentation-button"><a href="documentation.php">Documentation</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li class="dropdown">
@@ -32,3 +38,9 @@
</ul>
</div><!-- /.navbar-collapse -->
</nav>
+
+<script>
+ // Add the active class to the current pages button
+ var button = document.getElementsByName("<?php echo($button_name."-button"); ?>");
+ button[0].className += "active";
+</script>