Link to home
Start Free TrialLog in
Avatar of oo7ml
oo7ml

asked on

Display Different Graphic On Each Page

Hi,

I need to display a different graphic on each page of my site (in the top header).

www.mywebsite.com = graphic01.png
www.mywebsite.com/about = graphic02.png
www.mywebsite.com/contact = graphic03.png
www.mywebsite.com/portfolio = graphic04.png
www.mywebsite.com/services = graphic05.png

Then for all other pages, i just want to display the default graphic (graphic-default.png).

What would be the best way to accomplish this using PHP, thanks in advance for your help.
SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
@Chris: just wondering - did you test that code?
As a matter of fact i did.
Why you ask?

User generated image

(I admit the example is loosely written and requires url rewrite to be configured. It will be more stable using basename and various checks)
Just thinking out loud - what if there is a URL parameter request variable?  I think it might be worth isolating the desired substring(s) from the URL.  After I wrote, "switch()" I got to thinking that maybe it wasn't the right application for switch()!
My code doesn't handle that at all and in my opinion it should not.

Its an example that needs refinement (sure). But an example non the less. Copy-pasting any example in production without a second thought and precise consideration is bad practice in any situation. It should be rewritten to answer the requirements set out by the user matching its context, and thus needs 'work' ;-)

On how to overcome the risk you set out without masses of code, is by url rewrite: https://wiki.apache.org/httpd/RewriteQueryString. But this in my opinion is a different question.

But!
of course you are absolutely right the code in the example is a huge risk without additional coding.