Jump to content

Cart will only allow for one template trying to use PHP to solve problem


Recommended Posts

Hi Everyone,

 

I am still learning php but tried to write something to solve a problem I am having. A cart that I need to use will only allow for their template but it hooks into our POS system so I need to use it. It uses the same divs for both the inner page and home page making it harder to style. What I wanted to do since I can upload multiple stylesheets is try and use a if statement and say if it is the index.html page show this style sheet else show the standard inner page. Can someone tell me what I did wrong.

 

<?php if ( $_SERVER[sERVER_NAME] == "https://domain.com/index.htm" ){

echo '<link rel="stylesheet" href="graphics/styleshome.css" type="text/css" />';

}else{

echo '<link rel="stylesheet" href="graphics/styles.css" type="text/css" />';

}

?>

 

Thanks

$_SERVER['SERVER_NAME'] will only give you the domain

you probably want $_SERVER["PHP_SELF"],

 

Quick tip

add this line of code

echo "<!-- This file is:".$_SERVER["PHP_SELF"]." -->";

and load up the first template, and view source and look for 'This file is' copy the text after it, and use that in your statement ;)

 

also remember the $_GET maybe used to pick the page, ie ?page=home, you could use that instead ie

if ($_GET['page'] == 'home')

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.