开发者

Active link state help WORDPRESS

开发者 https://www.devze.com 2022-12-09 04:06 出处:网络
looking for some help:) http://69.65.3.168/~doubleop/pro.sperity/blog is the site i am working on, you can see the navigation is a drop down. I want the green to hover over active pages.

looking for some help:)

http://69.65.3.168/~doubleop/pro.sperity/blog

is the site i am working on, you can see the navigation is a drop down. I want the green to hover over active pages.

This is a drop down menu, so i created parent pages as the main nav links, and the drop down contains child pages.

All the links are hard coded at the moment, not using wordpress' built in function.

This is my code for the active links, which works well on normal .php sites, but not on wordpress

    <ul id="menu">
    <li <?php $string = basename($_SERVER['SCRIPT_FILENAME']); if ( strpos($string, 'index') !== false ){ echo "class='active'"; }else{ echo "class='nactive'"; } ?>><a href="http://69.65.3.168/~doubleop/pro.sperity/">Home</a>
<!--No drop downs-->
    </li>
    <li <?php $string = basename($_SERVER['SCRIPT_FILENAME']); if ( strpos($string, 'blog') !== false ){ echo "class='active'"; }else{ echo "class='nactive'"; } ?> ><a href="http://69.65.3.168/~doubleop/pro.sperity/blog">Blog</a>
<!--No drop downs-->
    </li>
    <li <?php $string = basename($_SERVER['SCRIPT_FILENAME']); if ( strpos($string, 'business-model') !== false ){ echo "class='active'"; }else{ echo "class='nactive'"; } ?> ><a href="http://69.65.3.168/~doubleop/pro.sperity/business-model">Business Model</a>
        <ul>
            <li><a href="http://69.65.3.168/~doubleop/pro.sperity/business-model/introduction">Introduction</a></li>
            <li><开发者_运维百科a href="http://69.65.3.168/~doubleop/pro.sperity/business-model/investment-strategy">Investment Strategy</a></li>
            <li><a href="http://69.65.3.168/~doubleop/pro.sperity/business-model/investor-benefits">Investor Benefits</a></li>
            <li><a href="http://69.65.3.168/~doubleop/pro.sperity/business-model/investment-programs">Investment Programs</a></li>
            <li><a href="http://69.65.3.168/~doubleop/pro.sperity/business-model/properity-partnership">Prosperity Partnership</a></li>
            <li><a href="http://69.65.3.168/~doubleop/pro.sperity/business-model/rrsp-investment">RRSP Investment</a></li>
            <li><a href="http://69.65.3.168/~doubleop/pro.sperity/business-model/limited-partnership">Limited Partnership</a></li>
            <li><a href="http://69.65.3.168/~doubleop/pro.sperity/business-model/refferal-program">Refferal Program</a></li>
            <li><a href="http://69.65.3.168/~doubleop/pro.sperity/business-model/faq">FAQ</a></li>
        </ul>
    </li>
        <li <?php $string = basename($_SERVER['SCRIPT_FILENAME']); if ( strpos($string, 'track-record') !== false ){ echo "class='active'"; }else{ echo "class='nactive'"; } ?> ><a href="http://69.65.3.168/~doubleop/pro.sperity/track-record">Tack Record</a>
        <ul>
            <li><a href="http://69.65.3.168/~doubleop/pro.sperity/track-record/company-overview">Company Overview</a></li>
            <li><a href="http://69.65.3.168/~doubleop/pro.sperity/track-record/investment-portfolio">Investment Portfolio</a></li>
            <li><a href="http://69.65.3.168/~doubleop/pro.sperity/track-record/why-prosperity">Why Prosperity</a></li>
            <li><a href="http://69.65.3.168/~doubleop/pro.sperity/track-record/testimonials">Testimonials</a></li>
        </ul>
    </li>
        <li <?php $string = basename($_SERVER['SCRIPT_FILENAME']); if ( strpos($string, 'current-oppertunities') !== false ){ echo "class='active'"; }else{ echo "class='nactive'"; } ?> ><a href="http://69.65.3.168/~doubleop/pro.sperity/current-oppertunities">Current Oppertunities</a>
        <ul>
            <li><a href="http://69.65.3.168/~doubleop/pro.sperity/current-oppertunities/current-offerings">Current Offerings</a></li>
            <li><a href="http://69.65.3.168/~doubleop/pro.sperity/current-oppertunities/ivestor-interest-form">Investor Interest Form</a></li>
            <li><a href="http://69.65.3.168/~doubleop/pro.sperity/current-oppertunities/properties-for-rent">Properties for Rent</a></li>
        </ul>
    </li>
        <li <?php $string = basename($_SERVER['SCRIPT_FILENAME']); if ( strpos($string, 'upcoming-events') !== false ){ echo "class='active'"; }else{ echo "class='nactive'"; } ?> ><a href="http://69.65.3.168/~doubleop/pro.sperity/upcoming-events-news">Upcoming Events &amp; News</a>
    </li>
        <li <?php $string = basename($_SERVER['SCRIPT_FILENAME']); if ( strpos($string, 'mentorship-program') !== false ){ echo "class='active'"; }else{ echo "class='nactive'"; } ?> ><a href="http://69.65.3.168/~doubleop/pro.sperity/mentorship-program">Mentorship Program</a>
    </li>
        <li <?php $string = basename($_SERVER['SCRIPT_FILENAME']); if ( strpos($string, 'about-us') !== false ){ echo "class='active'"; }else{ echo "class='nactive'"; } ?> ><a href="http://69.65.3.168/~doubleop/pro.sperity/about-us">About us</a>
        <ul>
            <li><a href="http://69.65.3.168/~doubleop/pro.sperity/about-us/mission-statement">Mission Statement</a></li>
            <li><a href="http://69.65.3.168/~doubleop/pro.sperity/about-us/management-team">Management Team</a></li>
            <li><a href="http://69.65.3.168/~doubleop/pro.sperity/about-us/contact">Contact</a></li>
        </ul>
</ul>

(the code is showing up wierdly, but you get the idea)

I tried echoing out the script_filename, and it was index.php on every page.

Anyone know how i can go about doing this? I need the active state to stay there when the user is on the relevant page, or any relevant child pages within under the parent

Thank you


$_SERVER['SCRIPT_FILENAME'] is the same on every page since Wordpress directs all pages to the same script for processing.

If you want to search the URI for a specific string, try using $_SERVER['REQUEST_URI'] instead; that returns the requested URI, regardless of which script is being executed.

Also, in the code supplied, you misspelled "inactive" as "nactive."

0

精彩评论

暂无评论...
验证码 换一张
取 消