dcuellar Posted March 5, 2008 Share Posted March 5, 2008 Hello all! I'd like to take the following and add a condition to it. I'd like for the photos to show up if they are on a certain page. For example, I have this system embedded on two pages. One for an online store and one for a linking system. I'd like to show these pictures while in the store, but another set of pictures while viewing the links page. <?xml version="1.0" encoding="utf-8"?> <photos path="fal_images/"> <photo name="Example Text 1" url="image1.jpg" link="http://www.hiphopeulogy.com/forum/cartplog.php?do=viewitem&cartplogproductid="></photo> <photo name="Example Text 2" url="image2.jpg" link="http://www.hiphopeulogy.com/forum/cartplog.php?do=viewitem&cartplogproductid="></photo> <photo name="Example Text 3" url="image3.jpg" link="http://www.hiphopeulogy.com/forum/cartplog.php?do=viewitem&cartplogproductid="></photo> <photo name="Example Text 4" url="image4.jpg" link="http://www.hiphopeulogy.com/forum/cartplog.php?do=viewitem&cartplogproductid="></photo> <photo name="Example Text 5" url="image5.jpg" link="http://www.hiphopeulogy.com/forum/cartplog.php?do=viewitem&cartplogproductid="></photo> <photo name="Example Text 6" url="image6.jpg" link="http://www.hiphopeulogy.com/forum/cartplog.php?do=viewitem&cartplogproductid="></photo> <photo name="Example Text 7" url="image7.jpg" link="http://www.hiphopeulogy.com/forum/cartplog.php?do=viewitem&cartplogproductid="></photo> <photo name="Example Text 8" url="image8.jpg" link="http://www.hiphopeulogy.com/forum/cartplog.php?do=viewitem&cartplogproductid="></photo> <photo name="Example Text 9" url="image9.jpg" link="http://www.hiphopeulogy.com/forum/cartplog.php?do=viewitem&cartplogproductid="></photo> </photos> Link to comment https://forums.phpfreaks.com/topic/94536-apply-image-on-certain-pages/ Share on other sites More sharing options...
bpops Posted March 5, 2008 Share Posted March 5, 2008 Check out the $_SERVER reserved variables in PHP. http://us2.php.net/reserved.variables You might do something like $page = $_SERVER['PHP_SELF']; if ($page == 'index.php'){ //display one photo }else{ //display another photo } Link to comment https://forums.phpfreaks.com/topic/94536-apply-image-on-certain-pages/#findComment-484090 Share on other sites More sharing options...
dcuellar Posted March 5, 2008 Author Share Posted March 5, 2008 So I would replace the 'index.php' with the page I am viewing? And, let's say for example I wanted to use all of the photos I have currently for this page...would I insert them between the {}? After the //display one photo? or would it be replacing the "//display one photo"? Link to comment https://forums.phpfreaks.com/topic/94536-apply-image-on-certain-pages/#findComment-484098 Share on other sites More sharing options...
bpops Posted March 5, 2008 Share Posted March 5, 2008 The idea is that the variable, $page, will contain the page that you are currently viewing. $page = $_SERVER['PHP_SELF']; So if you want a specific page to display a specific photo (or set of photos), then you need to check that $page contains the value you want. that's if($page == 'index.php'){ // put anything you want here. } The comment (//) is where you can put whatever php you want to display your html code. This is where you'll call the specific images for that page. Here's a slightly longer example using switch statements (instead of if): <?xml version="1.0" encoding="utf-8"?> <photos path="fal_images/"> <?php // Determine which page is being viewed $page = $_SERVER['PHP_SELF']; // Display photos specific to certain pages switch($page){ case 'index.php': // If viewing the index page echo '<photo name="Example Text 1" url="image1.jpg" link="http://www.hiphopeulogy.com/forum/cartplog.php?do=viewitem&cartplogproductid="></photo>'; break; case 'link.php': // If viewing the links page echo '<photo name="Example Text 2" url="image2.jpg" link="http://www.hiphopeulogy.com/forum/cartplog.php?do=viewitem&cartplogproductid="></photo>'; break; } ?> </photos> So this is just an example, you'll have to tailor it to how you want it. But hopefully that's a little clearer. Link to comment https://forums.phpfreaks.com/topic/94536-apply-image-on-certain-pages/#findComment-484181 Share on other sites More sharing options...
dcuellar Posted March 5, 2008 Author Share Posted March 5, 2008 now, what about the path of these php pages? my links page is under the root, but my store is not. links=public_html/links/index.php store=public_html/forum/cartplog.php Link to comment https://forums.phpfreaks.com/topic/94536-apply-image-on-certain-pages/#findComment-484358 Share on other sites More sharing options...
bpops Posted March 5, 2008 Share Posted March 5, 2008 Check out the link I gave you. $_SERVER has fields for path, too. Link to comment https://forums.phpfreaks.com/topic/94536-apply-image-on-certain-pages/#findComment-484363 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.