PHP to use current state of menu

Hi,

I found these pieces of PHP code helping me solving my problem of selecting and styling the menu of the current page. I’ve never worked with PHP before and ask for a bit of support.

  • How do I get the code into FW
  • Is the code correct
<?php if ( is_page('Page One') ) { $current = 'one'; } elseif ( is_page('Page Two') ) { $current = 'two'; } elseif ( is_page('Page Three') ) { $current = 'three'; } elseif ( is_page('Page Four') ) { $current = 'four'; } ?>

#<?php echo $current; ?> {
background-color: yellow;
}


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Hi Rob,
It looks like you’ve got a block of code from a WordPress site there.
is_page is a Wordpress PHP function that determines if the current
page is the same as the one you want to check against. Unless you are
planning to incorporate this into a WordPress site I’m sorry to say
that the code won’t work as it stands.

What you need a is a function that looks at the current link and
compares it to the page URL. If they match then you can set a style on
the link.

After about 30 seconds of searching I found this;
http://snipplr.com/view/3487/change-style-based-on-current-page/
which uses the page name (not the URL) to style the current page. It
should do what you need.

Regards,
Tim.

On 9 Dec 2009, at 14:45, RobP wrote:

I found these pieces of PHP code helping me solving my problem of
selecting and styling the menu of the current page. I’ve never
worked with PHP before and ask for a bit of support.

  • How do I get the code into FW
  • Is the code correct
<?php if ( is_page('Page One') ) { $current = 'one'; } elseif ( is_page('Page Two') ) { $current = 'two'; } elseif ( is_page('Page Three') ) { $current = 'three'; } elseif ( is_page('Page Four') ) { $current = 'four'; } ?>

#<?php echo $current; ?> {
background-color: yellow;
}

FreewayActions.com - Freeware and shareware actions for Freeway
Express & Pro.

Protect your mailto links from being harvested by spambots with Anti
Spam.
Only available at FreewayActions.com

http://www.freewayactions.com


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options