Page 1 of 1

Need function help... I am stuck on printing an image

Posted: Sun Sep 07, 2003 3:53 pm
by rprins
Ok, I am trying to write a function that will take the current page via a $PHP_SELF and then print a specific image that is unique for that page on that page. What this is being used for is to give the user some idea where they are on the site via a image between the top image and the content below. I have attmpted to write a function, but I must say I am not well versed in their doing. So, please offer any help to get me on the right path. What I have attempted so far is below.

There will be multiple pages that this is for, but I am just working on getting it to work for one at the moment. Also, I don't know an easy way to get just the index.php from a $PHP_SELF so, that is why I have the $rootpath."test.php" garbage.

Code: Select all

<?php
function print_pagetitle($loaded_page){

	$root_path = "/clanuw_v2/";

	if($loaded_page == $rootpath."test.php"){
		echo "<img src="images/news.gif" width="950" height="65" alt="Page Image">";
		return;
	}
}
?>
Called by:

Code: Select all

<?php print_pagetitle($PHP_SELF); ?>

Posted: Mon Sep 08, 2003 5:06 pm
by rprins
^^ BUMP ^^

Posted: Tue Sep 09, 2003 4:45 am
by twigletmac
Try using:

Code: Select all

<?php
function print_pagetitle($loaded_page) {
	
	$page_name = basename($loaded_page);

	if($page_name == 'test.php') {
		echo '<img src="images/news.gif" width="950" height="65" alt="Page Image">';
	}

	return;
}
?>
and calling it using:

Code: Select all

<?php print_pagetitle($_SERVER['PHP_SELF']); ?>
On a side note - I would avoid having an image longer than about 700 pixels except in exceptional circumstances - there are still a large percentage of users using 800 x 600 resolution.

Mac

Posted: Tue Sep 09, 2003 5:05 pm
by rprins
Thank You twigletmac!

BTW. The site was asked to be desigened for 1024x768 and this was just for testing purposes to have the image at 900px. It will become smaller down hte line.