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

Link to comment
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.