|
dynamic css in header
|
| robbieB |
Posted on 10-01-2011 19:23
|

Junior Member

Posts: 47
Joined: 31/07/2006
|
A script I'm trying to use to randomly rotate the background image in my site's header requires me to add the line:
echo "<style type='text/css' media='screen'> @import url('......[path ]....../dynamic_css.php');</style>\n";
between the <head> tags of the v7 header template. This works fine in Internet Explorer, but Firefox wont load the script from "dynamic_css.php" because it reads the MIME type as "text/html" not "text/css":
Error message: "The stylesheet "......[ path ]....../dynamic_css.php" was not loaded because its MIME type, "text/html", is not "text/css"."
The script includes a line which should tell the browser what type of file is being sent, but Firefox, Chrome, Safari, Opera etc. don't get the message:
// tell the browser what we're sending
header('Content-type: text/css');
I can get round this by declaring the style element twice, once inside the <head> tags and once outside. The random rotation script then works OK in all the browsers, but it screws up the page layout in Internet Explorer and also has a knock on effect on the CSS Dropdown Menu, which I also use (see www.rnsyc.net).
It's a case of "nearly but not quite", but I don't understand enough to see how to resolve it (except by waiting for Happy Svensson to include bg image rotation in the next version of his HappyAccidents theme :-)).
robbie |
| |
|
|
| SimpleVision |
Posted on 11-01-2011 08:32
|

Member

Posts: 63
Joined: 20/09/2010
|
please upload the code, which creates the problems
|
| |
|
|
| robbieB |
Posted on 11-01-2011 09:00
|

Junior Member

Posts: 47
Joined: 31/07/2006
|
SimpleVision wrote:
please upload the code, which creates the problems
www.thought-after...-rotation/ |
| |
|
|
| robbieB |
Posted on 17-01-2011 16:11
|

Junior Member

Posts: 47
Joined: 31/07/2006
|
robbieB wrote:
....... I can get round this by declaring the style element twice, once inside the <head> tags and once outside. The random rotation script then works OK in all the browsers, but it screws up the page layout in Internet Explorer and also has a knock on effect on the CSS Dropdown Menu, which I also use .....
An update for anyone interested. The problem with the layout in Internet Explorer just required some tweaking of the CSS Dropdown Menu. The other minor issue I've found was with the styles of the awec calendar infusion. In sum, the image rotation works but you can expect some minor knock-on problems with styles.
Even those minor issues may not arise if Firefox etc. could be got to load dynamic_css.php without having to declare the style element twice. Any suggestions as to how that might be done?
Thanks,
robbie
[Moderators: apologies but I first posted about this on the Themes forum (HappyAccidents theme). Maybe you'd prefer to move this thread over?]
Edited by robbieB on 17-01-2011 16:36
|
| |
|
|
| smokeman |
Posted on 17-01-2011 16:19
|

Veteran Member

Posts: 960
Joined: 23/06/2006
|
Im not sure here - I've earliere made a little script that rotates the banner in the header. Is this what your looking for ?
The script will change banner each time the page is being refreshed/loaded.
Edit: Try to see if you can use this:
1. Create a folder called banners which will be located in the directory /images/
2. In this example we use 5 banners to be chosen randomly from.
Banners / logos must be called:
banner1.gif
banner2.gif
banner3.gif
banner4.gif
banner5.gif
- And they must be in /images/banners/ - you can also use the extension .jpg images instead. Then you just change from .gif to .jpg in the code that follows below.
3. Log on to the site and go to Administration->System->Banners - here insert the following little snippet in the field "Banner 1" or "Banner 2":
<?php
$logo = rand(1,5);
echo "<img src='http://www.phpfusion-tips.dk/images/bannere/banner$logo.gif' alt='0' border='0' />";
?>
- Change only the URL to your own site.
In this case we used 5 banners to be chosen randomly from. For further / less banners to choose from then you just change the number 5 in the code, corresponding to the number of banners to choose from.
Edited by smokeman on 17-01-2011 16:51
|
| |
|
|
| robbieB |
Posted on 17-01-2011 16:42
|

Junior Member

Posts: 47
Joined: 31/07/2006
|
@smokeman
Thanks smokeman. Will try it.
robbie |
| |
|
|
| smokeman |
Posted on 17-01-2011 16:52
|

Veteran Member

Posts: 960
Joined: 23/06/2006
|
Oops - there was a small error in my code - when inserting it here in the forum, there was suddently some white/blank spaces that should'nt be there.
Please copy the code above again.
|
| |
|
|
| robbieB |
Posted on 17-01-2011 19:35
|

Junior Member

Posts: 47
Joined: 31/07/2006
|
@smokeman
I'm using Keff's HappyAccidents theme, which handles the header in a different way, i.e. background image + siteintro.
So your very neat code for rotating a banner image will require some tweaking of the theme.
Thanks again for the tip.
robbie |
| |
|
|
| smokeman |
Posted on 17-01-2011 19:39
|

Veteran Member

Posts: 960
Joined: 23/06/2006
|
No Problem - hehe, you can't use it anyway though..
|
| |
|
|
| robbieB |
Posted on 17-01-2011 19:53
|

Junior Member

Posts: 47
Joined: 31/07/2006
|

robbie |
| |
|