Page 1 of 1

Custom template with different header image

Posted: Thu May 31, 2007 4:02 am
by blue
hi,


As I read this site ( http://ubdc.net/ ) that each pages is showing their own header image, how can I do that? many thanks


angus

Re: Custom template with different header image

Posted: Thu May 31, 2007 6:49 am
by RonnyK
Check this post. It holds some info and also a link to another solution.

http://forum.cmsmadesimple.org/index.ph ... 547.0.html

Ronny

Re: Custom template with different header image

Posted: Thu May 31, 2007 11:22 am
by blue
RonnyK wrote: Check this post. It holds some info and also a link to another solution.

http://forum.cmsmadesimple.org/index.ph ... 547.0.html

Ronny
Hi Ronny,

I've read the link through the link you provided.
( http://wiki.cmsmadesimple.org/index.php ... y-position )
But I still don't understand where to put those code. Can you show me some more details for it.
eg: which file? (and also put in which directory?) I don't know what UDT is.

Thanks.

Re: Custom template with different header image

Posted: Thu May 31, 2007 12:13 pm
by RonnyK
UDT stands for User Defined Tag, which can be put under "Extensions -> User Defined Tags". You can create some code there that you can call in the templates to have the logic there.

Ronny

Re: Custom template with different header image

Posted: Thu May 31, 2007 5:00 pm
by blue
RonnyK wrote: UDT stands for User Defined Tag, which can be put under "Extensions -> User Defined Tags". You can create some code there that you can call in the templates to have the logic there.

Ronny
I see.
After I understand those ideas, it looks pretty stupid that every page title needs a unique css header.

So I make an automatic script that my client not needed to type css himself (he knows nth on the code).
all header image (using .jpg here) stored in the folder "images/cms/header/" and rename as the value of {$page_name} of that page.

The file "showHeaderImage.php" is stored in the root path.
ie: the same path as config.php

Code: Select all

<?php  //showHeaderImage.php
function LoadJpeg($imgname)
{
    $width = "1000";
    $height = "300";
    $im = @imagecreatefromjpeg($imgname); /* Attempt to open */
    if (!$im) { /* See if it failed */
        $im  = imagecreatetruecolor(386, 590); /* Create a black image */
        $bgc = imagecolorallocate($im, 255, 255, 255);
        $tc  = imagecolorallocate($im, 0, 0, 0);
        imagefilledrectangle($im, 0, 0, $width, $height, $bgc);
        /* Output an errmsg */
        imagestring($im, 1, 5, 5, "Error loading $imgname", $tc);
    }
    return $im;
}

$path = "./images/cms/header/"; // you have to create this folder yourself
if (isset($_REQUEST['page']) && file_exists($path . $_REQUEST['page'] . ".jpg"))
	$printImage = $_REQUEST['page'];
else
	$printImage = "home"; // this is the default header image

header("Content-Type: image/jpeg");
$img = LoadJpeg($path . $printImage . ".jpg");
imagejpeg($img);
?>
And then type this in your template:

Code: Select all

<img src="showHeaderImage.php?page={$page_name}" width="1000" height="300" />
But this still cannot solve the problem of page dependency. For example there's several pages under the hierarchy of "Products", all of them need to have their own custom header image or otherwise it will use the default one (home.jpg). So you may create them all or just copy and paste of the "Products" version.



Angus