WebsiteBaker Support (2.8.x) > Templates, Menus & Design

Standard logo and changing background

(1/4) > >>

Hans:
Hello fellow WB users,

I have found something like the following code here on the forum and I use it in combination with sections to give my customers an easy way to change header-images. When noting is set in a headersection with code
--- Code: ---page_content(2)
--- End code ---
the default image (here: standardheader.jpg) appears.


--- Code: ---<?php
ob_start();
page_content(2);
$out1 = ob_get_contents();
ob_end_clean();
if(empty($out1)) {
echo '<img src="http://www.awebsite.nl/media/headers/standardheader.png" alt="A website title" />';
} else { echo $out1; }
?>
--- End code ---

Now I am asked if it is possible to do the same but then to change the image not as "plain image" but as background-image. The client wants to place a logo over that background-image. That way he doesn't have to make headers-with-logo's but only one logo-image in the template that appears over the changing background header-images ;-)

Is that possible and is someone willing to share the code?
Thanks in advance
Hans

Argos:
Try changing this:


--- Code: ---<?php
ob_start();
page_content(2);
$out1 = ob_get_contents();
ob_end_clean();
if(empty($out1)) {
echo '<img src="http://www.awebsite.nl/media/headers/standardheader.png" alt="A website title" />';
} else { echo $out1; }
?>
--- End code ---

to this:


--- Code: ---<?php
ob_start();
page_content(2);
$out1 = ob_get_contents();
ob_end_clean();
if(empty($out1)) {
echo '<div style="background:url(http://www.awebsite.nl/media/headers/standardheader.png) 0 0 no-repeat;width:123px;height:123px;"></div>';
} else { echo '<div style="background:url('.$out1.') 0 0 no-repeat;width:123px;height:123px;"></div>'; }
?>
--- End code ---
You have to change 123px to the right size of your header. An empty DIV needs dimensions to show up.

Not tested though!

Hans:
Hello Jurgen

thanks for your code! Unfortunately there seems to be an error in it, please look at the attached screenshot. I changed both width and heigt to the real dimensions. Hope you can find a solution!
Hans

nibz:
I think the error is that the WYSIWYG by default put <img src="URL"> in.
And for your purpose you only need the url of the image. Not the whole img scr.

Argos:
Yes, of course, I should have tought about that. Hm... I'm sure there must be some solution. Let me think about it.

Navigation

[0] Message Index

[#] Next page

Go to full version