Page 1 of 1

I cannot get a background image to appear (css/smarty issue)

Posted: Sun May 30, 2004 4:14 pm
by Xephon
I have tried it like 10 different ways, but if the background file is in any other folder than root, it will not show up., then If i change the name of the backgrounbd file it will not show up (and yes i editied the code right :/)

and now i cannot even get that image to show up :/ at first i thought it was smarty treating the file wrong or something, then i foudn out to use literal, and still nothing.

It shows up in dreamweaver, but if i fire it up in IE it is just a plain white background :/

in the following code, the background.jpg file did not show up as the background even though it was in the root folder, and in the html folder (the file im about to show is in the html folder)

Code: Select all

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
&#123;literal&#125;
<style type="text/css">
body
&#123;
background-image: url("background.jpg");

&#125;
</style>

&#123;/literal&#125;
</head>

<body>
<table width=100%>
<tr>
<td width=75%>
&#123;if $news eq 0&#125;
No news to read
&#123;else&#125;
&#123;section name=i loop=$news&#125;
<table width="100%" border="1">
  <tr>
    <td width="15%" height="50">&#123;$news&#1111;i].post_date&#125;</td>
    <td width="85%">Posted by: &#123;$news&#1111;i].username&#125;</td>
  </tr>
  <tr>
    <td height="300">&</td>
    <td>&#123;$news&#1111;i].text_body&#125;</td>
  </tr>
</table> <a href=post.php>Post news Here!</a>
<br><br>
&#123;/section&#125;
&#123;/if&#125;
</td>

<td width=25%>
&#123;if $logged_in eq 1&#125;
<a href=logout.php>Logout</a>
&#123;else&#125;
&#123;include file="login_form.html"&#125;
&#123;/if&#125;

</td>
</tr>
</table

></body>
</html>
this is one of my template files, index.html

directory structure:

yorov3 - index.php is in here, and it calls index.html as the template
--------html - this is where index.html is
--------compile

and i have the background.jpg file in both the yorov3 and the html directories

any ideas/help would be highly appreciated

Posted: Sun May 30, 2004 4:18 pm
by JAM
If index.php is what the users see in the URI and it's calling a different file in a sub-dir, you need to add that sub-dir to the css also.

It's the index.php file that is processing the content, hence you wont see any background image. Try adding /html/ to that image reference.

Posted: Sun May 30, 2004 4:25 pm
by Xephon
i did, i have the image in every directory from the root down, and i have tried every variation of it too

background-image: url("background.jpg");
background-image: url(background.jpg);
background-image: url("/background.jpg");
background-image: url(/background.jpg);
background-image: url(html/background.jpg);
background-image: url(/html/background.jpg);
background-image: url("html/background.jpg");
background-image: url("/html/background.jpg");

and many many more, and still nothing

the source even shows the css right, but still nothing

Posted: Sun May 30, 2004 4:36 pm
by JAM

Code: Select all

background-image: url("./html/background.jpg");
?
./ refers to the "current" directory ( holding index.php )

Posted: Sun May 30, 2004 4:43 pm
by Xephon
fudging odd, but i made the picture smaller and it showed up :/

i wonder if the apache version i have craps out if it tries to load to big a picture or something :/

Posted: Sun May 30, 2004 4:45 pm
by JAM
Wierdness, but I don't think that is an issue. Perhaps something in the image was "broken" some how. Hope it worked out now tho.

Posted: Sun May 30, 2004 4:45 pm
by Xephon
arrrg then i try to put it in another directory, and change the image reference to the appropriate path, and nothing again

i dont know if it is css or if it is the smarty compiler, but i know i hate something lol

then i type in the path it is supposed to be in into my browser, and it says page cannot be found :/

http://127.0.0.1/yorov3/html/bg.jpg

but if i move it back up one directory, i see the picture

http://127.0.0.1/yorov3/bg.jpg

ps i know u cannot see the links, i was just saying what i typed into my borswer

Posted: Sun May 30, 2004 4:52 pm
by Xephon
well i just moved all the files out of yorov3, into the main root and now the picture shows up if i put it like this

background-image: url("/html/bg.jpg");

so i guess somehow my apache server does not even try to dig too far into any directory for an image file :/

Posted: Sun May 30, 2004 6:26 pm
by slimsam1
Xephon wrote:well i just moved all the files out of yorov3, into the main root and now the picture shows up if i put it like this

background-image: url("/html/bg.jpg");

so i guess somehow my apache server does not even try to dig too far into any directory for an image file :/
The beginning slash means "start at the root of the server" which is http://www.ipordomain.com/.

If you want to, you can move everything back in to yorov3, then change the line to read...
background-image: url("/yorov3/html/bg.jpg");

Re: I cannot get a background image to appear (css/smarty is

Posted: Thu Nov 01, 2012 10:31 pm
by nguyenkhang
Hi everybody!

I want share with you that you should put styles css on this .tpl page in tag :

{literal}
<style type="text/css">
body {
background-image: url('/ProjectName/imagesDirectory/background.img');
}
</style>
{/literal}

You should see again path to directory store that background images.

Sincerely,
Dong Nguyen Khang