3212 Posts in 847 Topics by 809 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1742 Views |
-
inline css in template

15 November 2009 at 2:11am
Hi out there,
maybe some one can help me.
I want to add an random image to my header. These images are in the image-folder from my template.
How can I access these files from the template --> Page.ss ?
I just inserted some lines of code and it works fine but there is no image
I think the relative path is wrong.
So my question is:How can I access these files from the Page.ss ?
Is there another possibility to get inline-css code into a template ?Greets
-
Re: inline css in template

15 November 2009 at 2:22am Last edited: 15 November 2009 2:23am
Hi markus85,
Please find the sample code to get the image from the folder
function getAllFiles($directory='') {
$result = array();
$folder = Director::baseFolder() . '/'.$directory.'thumb/';
$thumbdir = $directory.'thumb/';
$handle = opendir($folder);
$directorylist='';
while ($datei = readdir($handle))
{
if (($datei != '.') && ($datei != '..') && ($datei != 'Thumbs.db'))
{
$file = $thumbdir.$datei;
$abpath = $folder.$datei;
if (!is_dir($file)) {
$result[filemtime($abpath)] = $file;
}
}
}
closedir($handle);
foreach ($result as $val) {
$filename = basename($val);
$directorylist .= '<div><a href="'.$directory.$filename.'"><img src="'.$val.'" /></a></div>';
}
return $directorylist;
} -
Re: inline css in template

15 November 2009 at 2:48am Last edited: 15 November 2009 2:48am
Inline css in the template should be fine. If you want the path to the template folder, you can either enter the full path (relative to the site-base) or use the $ThemeDir variable in your template. Something like this:
<style type="text/css">
#MyHeader {
background: url($ThemeDir/images/myHeader.jpg) no-repeat left top;
}
</style> -
Re: inline css in template

15 November 2009 at 7:06am
thx for the answers.
Didn´t know about that variable $ThemeDir.Works fine
| 1742 Views | ||
|
Page:
1
|
Go to Top |



