Custom template with different header image

For discussion and questions related to CMS Specific templates and stylesheets (CSS), and themes. or layout issues. This is not a place for generic "I don't know CSS issues"
Post Reply
blue
New Member
New Member
Posts: 9
Joined: Tue May 22, 2007 8:56 am

Custom template with different header image

Post 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
RonnyK
Support Guru
Support Guru
Posts: 4962
Joined: Wed Oct 25, 2006 8:29 pm

Re: Custom template with different header image

Post 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
blue
New Member
New Member
Posts: 9
Joined: Tue May 22, 2007 8:56 am

Re: Custom template with different header image

Post 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.
RonnyK
Support Guru
Support Guru
Posts: 4962
Joined: Wed Oct 25, 2006 8:29 pm

Re: Custom template with different header image

Post 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
blue
New Member
New Member
Posts: 9
Joined: Tue May 22, 2007 8:56 am

Re: Custom template with different header image

Post 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
Post Reply

Return to “Layout and Design (CSS & HTML)”