Jump to content

Recommended Posts

Sorry I wasn't sure if I was suppose to start a new thread or not but here we go...

 

I'm checking to see if it's the homepage and if it is the homepage I would like the css to change.  but it is not working....any ideas?

 

if (!$_SERVER['QUERY_STRING']) {

    echo('<style type="text/css"><!--#page_bg {padding: 0;background: #000;} div.center { text-align: center; margin: 10px auto 0 auto; padding: 0; width: 900px; background: #ffffff url(../images/content_top.jpg) top center no-repeat--></style>');

 

}

 

thank you,

Andrea

 

if (!$_SERVER['QUERY_STRING']) {

    echo('<style type="text/css"><!--#page_bg {padding: 0;background: #000;} div.center { text-align: center; margin: 10px auto 0 auto; padding: 0; width: 900px; background: #ffffff url(../images/content_top.jpg) top center no-repeat--></style>');

 

}

Link to comment
https://forums.phpfreaks.com/topic/139704-solved-css-within-if-statement/
Share on other sites

You are placing it in the wrong place.  I checked out your site and you are printing the style block at the very top of the page.  You need to print the style block at the bottom of the <head> block.

 

It looks like you are using Joomla, so you will have to dig around in the templates to find out where it is. 

 

Here is the HTML for your web page.  I added a comment where you need to put your new styles.

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-gb" lang="en-gb" >
<head>
  <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  <meta name="robots" content="index, follow" />
  <meta name="keywords" content="joomla, Joomla" />
  <meta name="description" content="Joomla! - the dynamic portal engine and content management system" />
  <meta name="generator" content="Joomla! 1.5 - Open Source Content Management" />
  <title>Benedictine College School of Business</title>

  <link href="/index.php?format=feed&type=rss" rel="alternate" type="application/rss+xml" title="RSS 2.0" />
  <link href="/index.php?format=feed&type=atom" rel="alternate" type="application/atom+xml" title="Atom 1.0" />
  <link href="/templates/siteground-j15-48/favicon.ico" rel="shortcut icon" type="image/x-icon" />
  <script type="text/javascript" src="/media/system/js/mootools.js"></script>
  <script type="text/javascript" src="/media/system/js/caption.js"></script>


<link rel="stylesheet" href="/templates/system/css/system.css" type="text/css" />
<link rel="stylesheet" href="/templates/siteground-j15-48/css/template.css" type="text/css" />

<!-- YOU NEED YOUR HOMEPAGE SPECIFIC STYLES TO GO HERE -->
<?php if (!$_SERVER['QUERY_STRING']): ?>
<style type="text/css">
#page_bg {
    padding: 0;
    background: #000;
} 
div.center {   
    text-align: center;   
    margin: 10px auto 0 auto;   
    padding: 0;   
    width: 900px;   
    background: #ffffff url(../images/content_top.jpg) top center no-repeat
}
</style>
<?php endif; ?>

</head>

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.