...

View Full Version : multiple image script in dynamic website



lazyserv
11-28-2010, 06:34 PM
how can i make a specific image for specific page?

example:
http://example.com/index.php?page=home <-- use Image1 as logo
http://example.com/tour.php?page=country <-- use Image2 as logo
http://example.com/special.php?page=1 <-- use Image3 as logo

all is a dynamic script no database driven, and i only use one header.php
all my index.php tour.php and special.php include header.php only

so is it possible php do what i want?

DrDOS
11-28-2010, 06:55 PM
This would not be very hard to do, but without looking at your current code, I can't suggest any specific code. You just have to use an if statement somewhere, it could be where the tag for the logo image is.

lazyserv
11-29-2010, 04:33 AM
all right here is my current coding

index.php tour.php and service.php


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<?php include("/inc/header.php"); ?>
</head>

<body>
<?php include("/inc/navigation.php"); ?>
<!-- :::: Begin Content :::: -->
<?php
$pass = array('home','about','services','gallery','contact');
if (in_array(@$_GET['page'], $pass)) {
include ($_SERVER['DOCUMENT_ROOT'] . '/gunungraya/page/' . $_GET['page'] . '.php');
}
elseif (!isset($_GET['page'])) {
include ($_SERVER['DOCUMENT_ROOT'] . '/gunungraya/page/home.php');
}
else {
include ($_SERVER['DOCUMENT_ROOT'] . '/gunungraya/page/error.php');
}
?>
<?php include("/inc/footer.php"); ?>

</body>

</html>


header.php


<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<?php
function title_switch(){
$var = (isset($_GET['page']) && !empty($_GET['page']))?$_GET['page']:'home';
switch( $var ) {
case 'home':
$a['title'] = " &#187; Homepage";
$a['meta_d'] = "This page is about my site!";
$a['meta_k'] = "something, somethingelse";
$a['nivo'] = "<script src=\"./js/jquery.nivo.slider.pack.js\" type=\"text/javascript\"></script>\n";
$a['nivo_css'] = "<link href=\"./css/nivo-slider.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n";
break;
case 'about':
$a['title'] = " &#187; About Us";
$a['meta_d'] = "This page is about my site!";
$a['meta_k'] = "something, somethingelse";
break;
case 'services':
$a['title'] = " &#187; Services";
$a['meta_d'] = "This page is about my site!";
$a['meta_k'] = "something, somethingelse";
break;
case 'gallery':
$a['title'] = " &#187; Gallery";
$a['meta_d'] = "This page is about my site!";
$a['meta_k'] = "something, somethingelse";
break;
case 'contact':
$a['title'] = " &#187; Contact Us";
$a['meta_d'] = "This page is about my site!";
$a['meta_k'] = "something, somethingelse";
break;
default:
$a['title'] = " &#187; HTTP 404 - Page Not Found";
$a['meta_d'] = "";
$a['meta_k'] = "";
break;
}
return $a;
}
$details = title_switch();
?>
<meta content="<?php echo $details['meta_k']; ?>" name="keywords" />
<meta content="<?php echo $details['meta_d']; ?>" name="description" />
<link href="images/favicon.ico" rel="shortcut icon" />
<link href="./css/style.css" rel="stylesheet" type="text/css" />
<link href="./css/pirobox_lightbox.css" rel="stylesheet" type="text/css" />
<script src="./js/jquery.min.js" type="text/javascript"></script>
<script src="./js/jquery.easing.1.3.js" type="text/javascript"></script>
<script src="./js/pirobox.min.js" type="text/javascript"></script>
<script src="./js/global.js" type="text/javascript"></script>
<?php echo $details['nivo_css']; ?><?php echo $details['nivo']; ?>
<title>Gunung Raya Five Stars Express<?php echo $details['title']; ?></title>

navigation.php


<div class="main">
<div class="header_resize">
<div class="header">
<div class="logo">
<a href="./">
<img alt="logo" border="0" height="100" src="images/logo.gif" width="500" /></a></div>
<div class="clr">
</div>
</div>
</div>
<div class="body">
<div class="menu_bar">
<ul id="nav">
<li><a href="#">Parent 01</a></li>
<li><a class="selected" href="#">Parent 02</a>
<ul>
<li><a href="#">Item 01</a></li>
<li><a class="selected" href="#">Item 02</a></li>
<li><a href="#">Item 03</a></li>
</ul>
<div class="clear">
</div>
</li>
<li><a href="#">Parent 03</a>
<ul>
<li><a href="#">Item 04</a></li>
<li><a href="#">Item 05</a></li>
<li><a href="#">Item 06</a></li>
<li><a href="#">Item 07</a></li>
</ul>
<div class="clear">
</div>
</li>
<li><a href="#">Parent 04</a></li>
<li><a href="#">Parent 04</a></li>
<li><a href="#">Parent 04</a></li>
<li><a href="#">Parent 04</a></li>
<li><a href="#">Parent 04</a></li>
<li><a href="#">Parent 04</a></li>
</ul>
<div class="clr">
</div>
</div>


home.php


<div class="body_resize">
<div class="body_resize_top">
<div class="body_resize_bottom">
<!-- :::: Nivo Slider :::: -->
<div id="slider" style="margin-top: 5px;">
<img alt="" src="./images/slider/slide1.jpg" />
<img alt="" src="./images/slider/slide2.jpg" />
<a href="./" title=""><img alt="" src="./images/slider/slide3.jpg" title="Lorem ipsum dolor sit amet, consectetuer adipiscing elit" /></a>
</div>
<p style="margin-top: 20px;">Commoveo wisi nulla pala illum melior quis. Et luptatum validus wisi ingenium
humo quidne, eros lucidus dolore ea vel amet. Capto, praemitto singularis tation
duis consequat. Jus vulputate ingenium mauris ut, vero. Enim suscipit exerci eligo
dolus decet elit transverbero. </p>
<p>Opto tego, distineo luptatum, amet virtus ideo bene in, vindico eum. Voco, proprius,
tation jugis dolore consequat, adipiscing iusto eu, ingenium augue nimis, nostrud,
lucidus. Qui tristique uxor ibidem iriure bis praesent os. Consequat zelus pagus
abdo augue demoveo odio jus vel. </p>
<p>Commoveo wisi nulla pala illum melior quis. Et luptatum validus wisi ingenium
humo quidne, eros lucidus dolore ea vel amet. Capto, praemitto singularis tation
duis consequat. Jus vulputate ingenium mauris ut, vero. Enim suscipit exerci eligo
dolus decet elit transverbero. </p>
<p>Opto tego, distineo luptatum, amet virtus ideo bene in, vindico eum. Voco, proprius,
tation jugis dolore consequat, adipiscing iusto eu, ingenium augue nimis, nostrud,
lucidus. Qui tristique uxor ibidem iriure bis praesent os. Consequat zelus pagus
abdo augue demoveo odio jus vel. </p>
</div>
</div>
</div>
<div class="clr">
</div>


footer.php


<div class="footer">
<div class="footer_resize">
<a href="#">
<img alt="picture" border="0" class="loggo" height="61" src="images/footer_logo.gif" width="322" /></a>
<p class="right"><a href="#">
<img alt="picture" border="0" class="rss" height="16" src="images/rss_1.gif" width="16" /></a>
<a href="#">
<img alt="picture" border="0" class="rss" height="16" src="images/rss_2.gif" width="16" /></a>
<a href="#">
<img alt="picture" border="0" class="rss" height="16" src="images/rss_3.gif" width="16" /></a>
<a href="#">
<img alt="picture" border="0" class="rss" height="16" src="images/rss_4.gif" width="16" /></a>
Copyright websitename . All Rights Reserved<br />
<a href="#">Home</a> | <a href="#">Contact</a> | <a href="#">RSS</a></p>
<div class="clr">
</div>
</div>
<div class="clr">
</div>
</div>
</div>
</div>



i curently devoping offline file so i cant show u the site yet but attached togther is my screenshot of the web

http://img827.imageshack.us/img827/9119/73330166.gif

hope to hear from u soon, i willing to learn if u willing to teach me :x

DrDOS
11-29-2010, 05:34 AM
It's actually easier than I thought to make it work with your code, you don't even need to have any if statements. Just rename the logos you are using to home_logo.gif, about_logo.gif, services_logo.gif, etc, then change this line:

<img alt="logo" border="0" height="100" src="<?php echo 'images/'.$var.'_logo.gif'; ?>" width="500" /></a></div> That should work fine.

lazyserv
11-29-2010, 09:07 AM
but i only using a navigation.php

is it possible?

because all my page will be like this

example.com/index.php?page=home
example.com/index.php?page=about
example.com/tour.php?page=price
example.com/service.php?page=range

all index.php tour.php n service.php sharing a navigation.php where all my image file is located

DrDOS
11-29-2010, 03:46 PM
Is the index always using the same, logo, and tour always using the same logo? You can probably just add lines to the header php defining what logo to use in what case. Also, don't be afraid to just try it, it won't bite you. If what I suggested doesn't work we can refine things and try again.

lazyserv
11-29-2010, 04:10 PM
not working


<a href="./"><img alt="logo" border="0" height="100" src="<?php echo './images/'.$var.'_logo.png'; ?>" width="600" /></a>

the source


<a href="./"><img alt="logo" border="0" height="100" src="./images/_logo.png" width="600" /></a>

DrDOS
11-29-2010, 05:03 PM
Is $var defined before that code runs? Is the header included before it runs?

lazyserv
11-29-2010, 05:27 PM
yes or would u like to have a look at all i code? if yes i dont mind to email u.. because i kinda head now where did i go wrong

sent u a pm have a look

DrDOS
11-29-2010, 05:48 PM
If I had looked more closely I would have seen that it was. OK, I see why it doesn't work, $var is contained in the function title_switch and so something has to be included in the switch statements instead ( probably easiest ) and returned along with all the other stuff. So you just need to add a line to the switch statements for each logo, and use that variable instead.

lazyserv
11-29-2010, 06:07 PM
sorry to say i really dont know how to do it... what line i should add it?

DrDOS
11-29-2010, 07:00 PM
We've got it. Change this line in your navigation:

<img alt="logo" border="0" height="100" src="<?php echo './images/'.$details['logo']; ?>" width="600" /></a></div>

Add this line to all the case statements, but choose the logo file name you want for each page.

$a['logo'] = 'home_logo.png';You're welcome.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum