VISIT AND LIKE OUR PAGE ON FACEBOOK
TAKE A LOOK AT OUR TWEETS ON TWITTER
SUBSCRIBE TO THE JOOMFREAK RSS FEED
VISIT OUR CHANNEL ON YOUTUBE

Account Details

Change your name, email, password or permanently delete your account. Change settings

We offer several ways you can get support from our experts: Support ForumKnowledgebaseNewsletter

Your Forum Posts

No posts to display.

Welcome, Guest
Username Password: Remember me
  • Page:
  • 1

TOPIC: CSS and HTML

CSS and HTML 16 Jun 2012 21:09 #461

Hi Team,

I want to make random background, I did as below :
CSS file :
// Have my image under localhost/site/images/bg/<image file>
#jf-body {
padding: 0px;
margin: 0px;

background-image:url('<?php echo JURI::root(); ?>images/bg/<?php echo $bg_image; ?>');
background:url('<?php echo JURI::root(); ?>images/bg/<?php echo $bg_image; ?>');

/**background:url(../images/jf_body.png) repeat-x top left #666666';**/
}

Code under HTML:
<?php

// Array with associations: Itemid <-> background image
$bg_images = array(
"1" => "1.jpg",
"27" => "2.jpg",
"50" => "3.jpg",

"default" => "4.jpg" // default background image
);

$itemID_value = JRequest::getVar('Itemid');
$bg_image = (isset($bg_images[$itemID_value])) ? $bg_images[$itemID_value] : $bg_images["default"];
$url = JURI::root();
?>

I can see my file path correctly, but site doesn't get any it remains in white background. Please help.
Thanks .
Raj

  • Posts:6
  • rajwant
  • Fresh Boarder
  • OFFLINE
  • Karma: 0

Re: CSS and HTML 18 Jun 2012 03:09 #471

Hi
You can't use php code in css file. If you want to do that. You must to copy css code in index.php :
<style type="text/css" >
#jf-body {
padding: 0px;
margin: 0px;

background-image:url('<?php echo JURI::root(); ?>images/bg/<?php echo $bg_image; ?>');
background:url('<?php echo JURI::root(); ?>images/bg/<?php echo $bg_image; ?>');

/**background:url(../images/jf_body.png) repeat-x top left #666666';**/
}
</style>
  • mars

Re: CSS and HTML 04 Jul 2012 20:50 #579

Thanks Team,

I got it working.

Well done.

-Raj

  • Posts:6
  • rajwant
  • Fresh Boarder
  • OFFLINE
  • Karma: 0
  • Page:
  • 1
Time to create page: 0.76 seconds
Thursday 21 March 2019

joomfreak is not affiliated with or endorsed by the Joomla Project or Open Source Matters.
The Joomla logo is used under a limited license granted by Open Source Matters the trademark holder in the United States and other countries.