Jump to content

adirondak

New Members
  • Posts

    1
  • Joined

  • Last visited

    Never

Everything posted by adirondak

  1. I've been trying to implement the ID the Body Based on URL wordpress snippet. First issue seems to be a syntax error function curr_virtdir($echo=true){ $url = explode('/',$_SERVER['REQUEST_URI']); $dir = $url[1] ? $url[1] : 'home'; // defaults to this if in the root $dir = htmlentities(trim(strip_tags($dir))); // prevent injection into the DOM through this function if ($echo) echo $dir; return echo $dir; // ie. curr_virtdir(false) } function get_curr_virtdir(){ curr_virtdir(false); } I Get a syntax error on this line below return echo $dir; // ie. curr_virtdir(false) If i remove this line completly the script seems to work for in the following situation <body <?php id="<?php curr_virtdir(); ?>"> although I am trying to use the same functions as a conditional for my hardcoded navigation but it doesnt seem to work - any ideas? <li><a href="http://www.url.com/" class="<?php if ( get_curr_virtdir() == "home" ){echo "navhomecurrent";} else {echo "navhome";}?>">Home<span></span></a></li> <li><a href="http://www.url.com/solutions/solutions/" class="<?php if ( get_curr_virtdir() == "solutions" ){echo 'navsolutionscurrent';} else {echo 'navsolutions';}?>">Solutions<span></span></a></li> <li><a href="http://www.url.com/about-us/about-us/" class="<?php if ( get_curr_virtdir() == "about-us" ){echo "navaboutuscurrent";} else {echo "navaboutus";}?>">About us<span></span></a></li>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.