I have a navigation menu in my includes file, but I am having trouble echoing out the menu across my site. If I try and place the code as so, the page renders out mark up where the nav menu should be.
The code works somewhat if I do not add the <?php
function before the menu.
I'm wondering how do I echo this code out within a function. I've tried changing the single quotes to double, but I think I am getting confused by the echo that is within the li
in the menu.
A solution would be great.
Thanks
<?php
function nav() {
echo
<nav class='container'>
<ul>
<li><a <?php if (strpos($_SERVER['PHP_SELF'], 'current-journal')) echo 'class="current"';?> href="current-journal">CURRENT JOURNAL<span class="sub-nav">Our latest and greatest!</span></a></li>
<li><a <?php if (strpos($_SERVER['PHP_SELF'], 'submit')) echo 'class="current"';?> href="submit">SUBMIT<span class="sub-nav">Your writing</span></a></li>
<li><a <?php if (strpos($_SERVER['PHP_SELF'], 'submission-guidelines')) echo 'class="current"';?> href="submission-guidelines">SUBMISSION GUIDELINES<span class="sub-nav">Everything you need to know is here</span></a></li>
<li><a <?php if (strpos($_SERVER['PHP_SELF'], 'contributors')) echo 'class="current"';?> href="contributors">CONTRIBUTORS<span class="sub-nav">See who\'s in our magazine\'s latest issue</span></a></li>
<li><a <?php if (strpos($_SERVER['PHP_SELF'], 'past-journals')) echo 'class="current"';?> href="past-journals">PAST JOURNALS<span class="sub-nav">Browse our issue archives</span></a></li>
<li><a <?php if (strpos($_SERVER['PHP_SELF'], 'blog')) echo 'class="current"';?> href="blog">BLOG<span class="sub-nav">Just a blog</span></a></li>
</ul>
</nav>
}?>