If statement

3 posts by 2 authors in: Forums > CMS Builder
Last Post: November 6, 2008   (RSS)

By chassa2556 - November 6, 2008

Hi

I'm doing a opera website for a client and some of the shows link from the right panel of the home page to a show detail page. The problem is the client doesn't want the 'back to listing' link going back to the show listing page when the customer has originally come from the home page. However we don't want a 'back to home page' on every detail page.

Is there an 'if' statement that would say that if this customer has linked from the home page it would show a 'back to home page' link but if he has come from the usual route e.g via the listing page there isn't that link?

Re: [chassa2556] If statement

By Dave - November 6, 2008

Hi chassa2556,

From a user interface point of view it's better to have consistent navigation elements on a page. It's confusing for users if sometimes a link is there and sometimes it's not because they may not realize the reason.

One solution is to use a javascript link to go to the previous page they were on such as:

<A HREF="javascript:history.go(-1)">Go to previous page</A>

You could also use PHP to send them to the referer page:

<A HREF="<?php echo @$_SERVER['HTTP_REFERER'] ?>">Go to previous page</A>

To not show the link when you came from the index page you'd need to test the referer value for something unique that wasn't on the other pages. Such as (if referer contains "index.php" or something like that). The first step is to identify what you're going to test for to determine if the link should be shown or not.

Hope that helps!
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] If statement

By chassa2556 - November 6, 2008

Great that php a href did the job just grand thanks