Welcome, Guest. Please login or register.
Did you miss your activation email?
May 26, 2012, 09:23:45 PM

Login with username, password and session length
Search:     Advanced search
Wollen Sie dem WebsiteBaker Team beitreten?
Nähere Informationen finden Sie unter hier und auf unserer neuen Webseite.
155554 Posts in 21715 Topics by 7737 Members
Latest Member: gx-world
* Home Help Search Login Register
Pages: [1] 2   Go Down
Print
Author Topic: Different background image for every single page  (Read 5887 times)
virgil

Offline Offline

Posts: 177



« on: July 05, 2006, 02:29:07 PM »

Hi evereybody

I once used with the multiple content block a separate content block2 to give to every single page a different banner...

Now I have a similar problem: I want a different background image for every single page, no matter if the page is placed in
- the body, or
- a table, or
- a table cell, or
- a "div"... so something like:

<body background="blablabla.gif"> or
<table background="blablabla.gif" > <tr><td>...</td></tr></table>
... and so on ...

---

HOW can I manage to have the "blablabla.gif" changed for every page I create?
I thought of using in the template a own contentblock (say '3')...something like:

<body background="<?php page_content(3); /* BG-Image */ ?>"> or so... ??

...but then I have the problem, that the code of the content block doesn't match to replace just "blablabla.gif"

Any ideas?

Thank you
Virgil


 
Logged

Virgil - the pre-baked-stuff baker -   wink)
pcwacht
Guest
« Reply #1 on: July 05, 2006, 03:45:32 PM »


Try some php wich uses the PAGE_ID to determine the correct image

Something like
Code:
echo PAGE_ID;
or
Code:
echo 'image'.PAGE_ID.'.jpg';

You can put the code in a code section or in the template's index.php


John
Logged
virgil

Offline Offline

Posts: 177



« Reply #2 on: July 05, 2006, 05:16:46 PM »

Hi John
Thx for your reply...

unfortunatly you're talking to a php coding idiot... embarassed

Could you please make it a little bit more 'transparent' to me?

1.) What do I exactly enter in my index(.)php?
2.) How and where do I assign the bg-pic to the page?

Thx for enlightening me  rolleyes

Cheers
Virgil
Logged

Virgil - the pre-baked-stuff baker -   wink)
pcwacht
Guest
« Reply #3 on: July 05, 2006, 07:31:54 PM »

Let's just asume you want to modify this:

Code:
<body background="blablabla.gif">
for page1 and
Code:
<body background="blablabla-another.gif">
for page2 etc etc
This basic html code is something wich is in your templates index.php
What you need to do is rename the pictures to picture1.gif and picture2.gif etc etc, one for each page_id you make (page_id is internal counter for wb)

Open up your index.php (templateeditor might do this easy)
change the
Code:
<body background="blablabla.gif">
to
Code:
<body background="<?php echo 'picture'.PAGE_ID.'.gif'?>">
What it does:
<body background=" -> html stuff
<?php => what follows is php
echo 'picture'.PAGE_ID.'.gif'; ->
echo -> show on the screen what is between ' and  ' is echoed literally, the . is for glueing outputs together, the PAGE_ID is a variable holding the pageid, the ; means end of command
?> stops php coding and return to basic html

If PAGE_ID hold the value 3 the output will be
Code:
<body background="picture3.gif">
if PAGE_ID holds 5
Code:
<body background="picture5.gif">

That is basicly all


You could allso use the pagename or anyother thing WB holds as variables

Good luck,
John
Logged
virgil

Offline Offline

Posts: 177



« Reply #4 on: July 05, 2006, 11:38:47 PM »

Hi John

Thx for the eloquent explanation, that sounds great... just to make it sure:

Let's say I would upload in the folder http:// www. mydomain.com /media/backgrounds/
picture1.gif, picture2.gif, picture3.gif, picture4.gif, and so on...then this pictures would match the pages with IDs 1, 2, 3,, and so on.... right?

Question: How do I know (as normal user... without access to DB) the pages IDs?

Quote
You could allso use the pagename [...] WB holds as variables

this sounds more easy to me... code like this huh
Code:
<body background="<?php echo WB_URL.'/media/backgrounds/'.'PAGE_NAME.'.gif'; ?>">

Thx for your patience  rolleyes

Cheers
Virgil
Logged

Virgil - the pre-baked-stuff baker -   wink)
pcwacht
Guest
« Reply #5 on: July 06, 2006, 07:19:35 AM »

Know your page id, admin -> pages, edit the page, look at link in browsers address bar

The code for page_name

Try either PAGE_TITLE or MENU_TITLE
Code:
<body background="<?php echo WB_URL.'/media/backgrounds/'.'PAGE_TITLE.'.gif'; ?>">

Check with spaces in the name though... not sure  if it will work. Think it will 80%


John
Logged
Fredflintstone

Offline Offline

Posts: 74


« Reply #6 on: September 14, 2006, 11:37:26 AM »

Hi,
I've read this with a lot of interest because I've got a similar situation but :!

I'm setting up a site for a lodge-b&b association.
In this site, every member has got an introduction page with a link to it's own website.
Once the site will be up and running, the admin will be done by a member of the  association.
Basically this will be updating excisting pages, but in time, there will be new members and thus new pages.
In other words, I won't be there to link a picture to the new page...
My question now is:  is it not possible that I put 10-15 pictures in a folder, and that the background picture gets generated randomly from these pictures?
Maybe my "new page problem" could be solved like this .

Thanks for any suggestions

Awaiting with high expectations  grin

Edwin

Logged
kweitzel
Forum administrator
*****
Offline Offline

Posts: 6977


WWW
« Reply #7 on: September 14, 2006, 11:57:33 AM »

there is a little snippet called "random image" which does exactly this ... you upload some images into the mediafolder and the script randomly chooses one of these images.

It is available in the Add-On Repository(which currently redirects) in the modules section.

cheers

Klaus
Logged

WebsiteBaker Org e.V. - for WebsiteBaker

Fredflintstone

Offline Offline

Posts: 74


« Reply #8 on: September 14, 2006, 10:30:47 PM »

Hi Klaus!,

Txs again for the tip, but as you most propably already where affraid of,  afro I still need some help to get this going.
I've installed the module, created a folder :.../media/ background/
and now?

Point is, I want this pictures as background pics... so, how do I get them  to show up there?

TXS

Edwin
Logged
kweitzel
Forum administrator
*****
Offline Offline

Posts: 6977


WWW
« Reply #9 on: September 15, 2006, 12:26:13 AM »

the image is called by placing following call to the template:

Code:
<?php RandomImage ('/media/background/random'); ?>

Instead of passing the background in the CSS File you could place tis call in the body tag. You need to modify the file "include(.)php" Take the last Line and change it to (I think, not tested):
Code:
echo '<'.WB_URL.$dir.'/'.$image.'';

Then again in your template something like this should work:

Code:
<body background="<?php RandomImage ('/media/background'); ?>">

cheers

Klaus
Logged

WebsiteBaker Org e.V. - for WebsiteBaker

Fredflintstone

Offline Offline

Posts: 74


« Reply #10 on: September 15, 2006, 01:38:02 AM »

Whooow Klaus...this is a bit too fast for me ... I'm still a newbee remember smiley

Do I have to do all 3 steps or are this different solutions?

Then:

Quote
the image is called by placing following call to the template:


Code:
<?php RandomImage ('/media/background/random'); ?>
Are you refering to the index.php of the template I'm using?
And if does it makes a difference where ( on what line)  I add this ?



Quote
Instead of passing the background in the CSS File you could place tis call in the body tag. You need to modify the file "include(.)php" Take the last Line and change it to (I think, not tested):

Code:
echo '<'.WB_URL.$dir.'/'.$image.'';
In which folder do I find the include.php and is the WB_URL just the Root where WB is installed ?


Quote
Then again in your template something like this should work:


Code:
<body background="<?php RandomImage ('/media/background'); ?>">

Again, which template and where in that template  ?

Thanks

Edwin
Logged
kweitzel
Forum administrator
*****
Offline Offline

Posts: 6977


WWW
« Reply #11 on: September 15, 2006, 05:08:10 AM »

OK ... sorry to confuse you ... I am talking about the template you want to use for the site.

the first line would be called anywhere in the template where you want to display a random image. It is just the general call.

The second and thrid lines are the one for your Template. You need to do both. Change the include of the module and calling the script in the body tag.

I assumed you wanted the complete body to be showing the random image as background, therefor I put it in the body tag. The body tag opens the "display area" of the browser. It is the first statement of a HTML Page (in this case a template) which affects the display of a webpage.

Hope that clearifies the whole idea I have ...

cheers

Klaus
Logged

WebsiteBaker Org e.V. - for WebsiteBaker

Fredflintstone

Offline Offline

Posts: 74


« Reply #12 on: September 15, 2006, 09:52:33 AM »

Damn...
Still strugling Klaus ...  embarassed

1- Where do I find  "the include " Huh?
2- Can I add the third code you gave me anywhere between the <body> and the </body> tags in the index.php file in my template ? ( at least that's where I think you want me to put it ) 

Now another thing.... maybe it isn't so simple , but I would like to use the ccshover template for this site.
If I look at the stylesheet there's something like this :

Quote
body {
      background  : url(pagebckgrnd.gif) #eee;
      margin      : 15px 10px 10px 25px;
   }
"
Would it not be possible to just (instead of the "url(pagebckgrnd.gif)" ) refer to the random picture there?
Something like url(media/background/random)...  and do nothing on the php part of the template???

But as I said... maybe It's just not so simple, but one can only try isn'it ?

BTW.. if you get tired of me , just push the "ignore button "  smiley

Txs a lot,

Edwin
Logged
kweitzel
Forum administrator
*****
Offline Offline

Posts: 6977


WWW
« Reply #13 on: September 15, 2006, 12:29:24 PM »

Hi Edwin,

1) Once you install the module "random image" from the Add-On Repository it creates a folder called random_image in the modules directory of your WB installation. There you find the file include(.)php which you will need to edit.

2) In your template (the file index(.)php of your template) you need to replace the existing body tag:

Code:
<body>

 with the new one:

Code:
<body background="<?php RandomImage ('/media/background'); ?>">

The Body tag is, like said above the opener for the display area. There you can set the background (in "old" HTML Style).

The CSS value for body will then be overwriten by the above code (if it works, like said, not yet tested). To be shure remove the following part of the code you posted:

Quote
url(pagebckgrnd.gif)

cheers

Klaus

Logged

WebsiteBaker Org e.V. - for WebsiteBaker

kweitzel
Forum administrator
*****
Offline Offline

Posts: 6977


WWW
« Reply #14 on: September 15, 2006, 01:00:07 PM »

OK ... just to make it a bit easier, I have modified the module for you, here it is. Install it like any other module and place this body tag to try:

Code:
<body style="background-image:url(<?php RandomImage ('/media/random'); ?>)">

I tested this and it works!

cheers

Klaus
Logged

WebsiteBaker Org e.V. - for WebsiteBaker

Fredflintstone

Offline Offline

Posts: 74


« Reply #15 on: September 16, 2006, 09:51:45 AM »

Hi Klaus !

Easy as if I've been doing this all my life!!!!!!!!  grin

Thanks a lot man!

Have a look at : http://www.elephantcoasttourism.com/wb/ it' s under constuction ( the content has to be filled in ) but the frame is starting to look damn good!  ( i think smiley ) !

Can't believe what a community here !

Again, thanks a million , and I haven't forgotten about the donation !

Edwin
Logged
Fredflintstone

Offline Offline

Posts: 74


« Reply #16 on: September 30, 2006, 11:15:22 AM »

Hi guys,
I wanted to try to have a random picture in my heading now,

I created a folder '/media/header/
I copied the call below into the header part of the template.:

<?php RandomImage ('/media/header'); ?>

The result is this error, showing on top of the old header picture:

Quote
Warning: getimagesize(http://www.elephantcoasttourism.com/wb/media/header/indaba 2006 003.jpg) [function.getimagesize]: failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request in /home/elephant/public_html/wb/modules/randomimage/include.php on line 30
http://www.elephantcoasttourism.com/wb/media/header/indaba 2006 003.jpg

I recon there's something I have to add or change in the '/modules/randomimage/include.php or am I doing this completely wrong now ?
Something is working at least , because : "indaba 2006 003.jpg " is one of the images I uploaded to the '/media/header/ folder.
 

Txs,

Edwin
Logged
kweitzel
Forum administrator
*****
Offline Offline

Posts: 6977


WWW
« Reply #17 on: September 30, 2006, 05:36:18 PM »

I rewrote the output for you, so this module ONLY works with the background. You need to change the original snipet module to be able to get this working.

The function needs to be renamed so that the function call is different and the module needs to be renamed (also the include file info).

cheers

Klaus
Logged

WebsiteBaker Org e.V. - for WebsiteBaker

Fredflintstone

Offline Offline

Posts: 74


« Reply #18 on: October 02, 2006, 10:31:05 AM »

Any chance you would do the same for the random picture in header and adding both snippets to the WB modules list ?
The one for the background works like a dream, so I can imagine there will be more people who would use these random picture snippets.

Hopefull  rolleyes,

Edwin

Logged
kweitzel
Forum administrator
*****
Offline Offline

Posts: 6977


WWW
« Reply #19 on: October 02, 2006, 11:22:23 AM »

Edwin,

 just take the original one and the one I made for you. Uninstall them in your current instalation and then reinstall "randomimage".

Then, n the on I made for you, rename the function to "randombackground" and the do the same with the info(.)php of that file.

Change the call in the body tag and off you go ...

cheers

Klaus
Logged

WebsiteBaker Org e.V. - for WebsiteBaker

Fredflintstone

Offline Offline

Posts: 74


« Reply #20 on: October 02, 2006, 12:33:16 PM »

Sorry Klaus,

Can't get it figured out ! ( maybe i should just stick to frontpage  cry )
There's only one way for me to get grip on these things and that's when you explain it step by step.
Where and how exactly do i do this :
Quote
Then, n the on I made for you, rename the function to "randombackground" and the do the same with the info(.)php of that file.

As usuall, I can only thank you for your help and If you get fed-up with it , I recon I will hear it ,

Edwin


Logged
kweitzel
Forum administrator
*****
Offline Offline

Posts: 6977


WWW
« Reply #21 on: October 02, 2006, 02:41:50 PM »

Step by Step (I might put that one up in the WIKI)

  • Uninstall the Module RandomImage
  • Download RandomImage again from the Add-On Repository and install it
  • Donwload RandomBackground and install it
  • Change your Template:
  • exchange the body tag with:<body background="<?php RandomBackground ('/media/background'); ?>">
  • place the Random Image call where you want it.
[li]test the template[/li]
[li]donate $25 to website Baker via paypal (optional)[/li]
[/list]
evil

OK ... thak OK for you?

cheers

Klaus
Logged

WebsiteBaker Org e.V. - for WebsiteBaker

Fredflintstone

Offline Offline

Posts: 74


« Reply #22 on: October 02, 2006, 05:38:30 PM »

Sorry Klaus,

Installing randombackground gives an error:

" Parse error: parse error, unexpected T_CONSTANT_ENCAPSED _STRING in /home/elephant/public_html/wb/temp/unzip/info.php on line 9 "

I just tried to install it as any other mod.
If I look at the /temp folder, 
-an  /unzip folder has been created with the include.php and the info.php in it
- the complete randombackground.zi p file is also copied to the  folder


Edwin

Logged
kweitzel
Forum administrator
*****
Offline Offline

Posts: 6977


WWW
« Reply #23 on: October 02, 2006, 05:53:48 PM »

had a fault in the info file, here is the updated version.

cheers

Klaus
Logged

WebsiteBaker Org e.V. - for WebsiteBaker

Fredflintstone

Offline Offline

Posts: 74


« Reply #24 on: October 03, 2006, 09:31:09 AM »

Hi Klaus,

Almost afraid to say this, but :

"Parse error: parse error, unexpected $ in /home/elephant/public_html/wb/temp/unzip/info.php on line 10"


Edwin
Logged
Pages: [1] 2   Go Up
Print
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!