Jump to content

apply image on certain pages


dcuellar

Recommended Posts

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

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"?

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.