Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Page specific body id/class tags


sphinx797

Recommended Posts

Hi all I'm trying to have a background specific image that only applies to the index.php page - my setup is a little complicated as I would like it to scroll left and right which isn't easy to do using the 960 grid.

 

So what I'm trying to do is create a PHP if / then statement that checks the current page and then gives it the correct string to output for my CSS id style

 

something like this but i can't seem to figure out where I'm going wrong. I know $page isn't really the way to get the filename but I can't figure out how else to get it.

 

<body id="<?php if ($page == FILENAME_DEFAULT) { echo 'mynewcssid';}?>">

Link to comment
Share on other sites

Try:

 

<body id="<?php if (basename($PHP_SELF) == FILENAME_DEFAULT) { echo 'mynewcssid';}?>">

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

Link to comment
Share on other sites

Ah germ that worked great. I couldn't remember how to call the page name for some reason.

 

Unfortunately I just realized that all Categories/subcategories display using index.php anyway so my background displays along with them which is not what i want. Works great on other pages though. Would be very useful for an admin mod bg changer contribution.

 

I'm trying to figure out a way to do this but can't seem to isolate just index.php and not /index.php?/hardware-c22.html

 

I really appreciate your help germ!

Link to comment
Share on other sites

SOLVED UPDATE:

 

I figured out that comparing the current URL solved the issue with index.php being used for the categories/subcategories. basename($PHP_SELF) works great for unique pages though.

 

Here's my working code for a variable <div> id:

 

<div id="<?php if ($_SERVER['HTTP_HOST']  . $_SERVER['REQUEST_URI'] == 'www.mysite.com/catalog/') { echo 'stagebg';}?>">

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...