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.
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
@Chris: just wondering - did you test that code?
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.
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.