Advertisement:

need help with adding a function

Aloittaja Bierbuikje, joulukuu 23, 2011, 06:28:42 AP

« edellinen - seuraava »

Bierbuikje

Hello, I'm making a theme for a forum but I experience some issues. I want to create an image before the body and behind the wrapper. I don't easily add it to the background of the body (in .css) because I want to add some code to this image later on, and that wouldn't be possible with that. So I decided to add the image to the index.template. I started with this code:

echo '
<div id="photo"><img src="', $settings['images_url'], '/photo.png" alt="' . $context['forum_name'] . '" /></div>';


I added it at various places to see what it did but it only messed with the wrapper and directly below the <body> code didn't work. So I tried to add a function.

<body>';
}

function photo_image()
{
global $context, $settings;

echo '
<div id="photo"><img src="', $settings['images_url'], '/photo.png" alt="' . $context['forum_name'] . '" /></div>';
}

function template_body_above()


The sad thing is that I have the idea that the function doesn't even load. It doesn't appear even in the source code of the website, maybe it needs to be loaded with another code, but I have no idea which.

My question: do I need to load the function photo_image somewhere? And if true, where? Else I would like to know how to put an image behind the wrapper and before the body.

Thanks a lot!

Bierbuikje

Ricky.

For me its not clear what you want to do ..

Why you need to add that function. ..

From what I concluded, you need a  background image in whole body but want to change it or something, then you can do something like :

echo '
<body' , !empty($settings['your_photo']) ? ' style = "background-image: abc.png"' : '', '>' ;

Where $settings['your_photo'] can be created by adding array variable in Settings.template.php (found inside your theme folder) , there are many similar variable there, so you can understand it.  and also remember to give full path to image ie. abc.png

Bierbuikje

Lainaus käyttäjältä: Ricky. - joulukuu 23, 2011, 06:44:07 AP
For me its not clear what you want to do ..
I made a schematic view of what I want to do.



Bottom layer the body, middle layer is the image and the top layer the wrapper/forum. I do this in a function cause I tried to add the <div> to 'template_body_above' and that places the image in the wrapper. I also tried to add id directly under the <body> code, but that didn't even show so I try to create a whole new function.

Ricky.

Generally smf goes like this :

<body>
<wrapper>
<content sections and stuff>
</wrapper>
</body>

Now you want another layer between body and wrapper..

Make it :
<body>
<div id="new_wrapper">
<wrapper>
<content sections and stuff>
</wrapper>
[/b]</div>[/b]
</body>

And add any image as background in it.. Just to add here, your index.template.php contains everything in order, just <content sections and stuff> is loaded from other templates.. so you most of the control ie. header footer etc. from this file only.

Bierbuikje

I got it working. I edited the 'margin-top: xxx px;' to a negative number. Thanks for your help Ricky. ;)

Advertisement: