Solved

add additional url to existing script

Posted on 2010-11-29
6
248 Views
Last Modified: 2012-08-14
I have a script that displays a "DEMO" image in the header of every page but the home page. I would like to add another page (url) where the "DEMO" image doesn't show (i.e. the DEMO page). It's probably very simple, I just don't know the syntax (it's not my script).

FYI, this is the part of the script that determines the page that does NOT show the image:

if(curPageURL() == 'http://www.realwalkthru.com/testing/')

Thanks,
Kyle
<?php 

function curPageURL() {
 $pageURL = 'http';
 if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
 $pageURL .= "://";
 if ($_SERVER["SERVER_PORT"] != "80") {
  $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
 } else {
  $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
 }
 return $pageURL;
}

if(curPageURL() == 'http://www.realwalkthru.com/testing/')

print '<div id="logoDemo">
  <div id="logo" class="fllft"><a href="http://www.realwalkthru.com/testing/"><img src="http://www.realwalkthru.com/testing/images/home/logo.jpg" border="0"/></a></div></div>'; 
else 
print 
'<div id="logoDemo">
  <div id="logo" class="fllft"><a href="http://www.realwalkthru.com/testing/"><img src="http://www.realwalkthru.com/testing/images/home/logo.jpg" border="0"/></a></div><div class="flrgt"><a href="demo.php"><img src="http://www.realwalkthru.com/testing/images/home/demoButt.gif" border="0" style="padding:45px 20px 0px 0px;"></a></div></div>';

?>

Open in new window

0
Comment
Question by:Kyle Hamilton
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 17

Expert Comment

by:sweetfa2
ID: 34235386
Replace the last </div> on line 18 with

<div class="flrgt"><a href="your page"><img src="your new image url" border="0" style="padding:45px 20px 0px 0px;"></a></div></div>

Open in new window

0
 
LVL 25

Author Comment

by:Kyle Hamilton
ID: 34235591
Thanks for the response, but that's not going to help.

Sorry I didn't explain this better.

The header is an include file which is used on every page of the site. The reason I have the PHP script in there in the first place is so that I don't have to use a separate header file for the home page (for example, if I make a change to the menus, I won't have to make it twice). At the moment the home page is the only page that does not have the "demo" button in the header. That's what the script does.

What I want to achieve is to add another page (i.e. the "demo" page), to the script, so it too, won't display the "demo" button in the header.

It's probably something like writing an array of urls, but I don't know how to do it.

Cheers
0
 
LVL 17

Expert Comment

by:sweetfa2
ID: 34235723
$urlset = array('http://www.realwalkthru.com/testing/', 'someotherurl','andanotherurl');

function inArray( $url) {
   foreach ($urlset as $value) {
      if ($url = $value) return true;
  }
  return false;
}


if(inArray(curPageURL()) == true)

Open in new window

0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
LVL 25

Author Comment

by:Kyle Hamilton
ID: 34235758
That's exactly what I'm looking for! cheers.

One glitch though... I'm getting this error:

Warning: Invalid argument supplied for foreach()
0
 
LVL 17

Accepted Solution

by:
sweetfa2 earned 500 total points
ID: 34235859
pass urlset as an argument to the function.

function inArray( $urlset, $url) {

if(inArray($urlset, curPageURL()) == true)

Also the comparison in the function needs to be "==" not "="

if ($url == $value) return true;
0
 
LVL 25

Author Closing Comment

by:Kyle Hamilton
ID: 34235900
You're special. Thank you so much!
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question