I have an image in the sidebar, using the HTML Nugget:
Code: Select all
<div id="nugget"></div>
"nuggetpic.png" is a folder, not a file. The folder contains a index.php:#nugget {
width:305px;
height:250px;
margin:0 auto;
background: url("{TEMPLATE_PATH}img/nuggetpic.png") top right no-repeat;
}
Code: Select all
<?php Header("Content-Type: image/gif");
$sigarray=array();
if ($handle = opendir("./")) {
while (false !== ($file = readdir($handle))) {
if(stristr($file, ".gif") or stristr($file, ".jpg") or stristr($file, ".png")){
array_push($sigarray,$file);} } }
closedir($handle);
shuffle($sigarray);
readfile(end($sigarray));?>
Problem: The images load very slow and the "random" doesn't work well. It takes a couple of refreshes to get another image. That's why, instead of random, I'd like to call the images by page alias (category AND static pages). So when static page "profile" is called, the image "profile.png" would be load. When category "education" is called, the image "education.png" is called. When no alias matches, a fallback image is called.
At least, that's how I call a individual banner per page on my homepage. But I can't figure out what "alias" to use in case of serendipity when applying it to static pages AND categories. Is that even possible? Or am I on a completely wrong track on how to adapt my homepage script? Or is there maybe a plugin solution I can abuse for this?
This is how I have it on my little homepage (no blog system):
index.php
Code: Select all
<div id="header"><img src="<?php include("inc/banner.php") ;?>" alt="banner" /></div>
Code: Select all
<?php
if(isset($_GET['section']) AND isset($banner[$_GET['section']])) {
echo $banner[$_GET['section']];
} else {
echo $banner['home'];
}
?>
Code: Select all
// banner
$banner = array();
$banner['home'] = "inc/banner/home.png";
$banner['links'] = "inc/banner/links.png";
[...]
Questions, questions,... I promise this is the last for now ^^;
~eni