News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Help for Banner position

Started by GoldLion, April 02, 2022, 03:27:46 PM

Previous topic - Next topic

GoldLion

Hello, can you direct me where in the code I can insert a banner / photo with a hyperlink to the given store.
In the photo I have shown where I want the position of the banner to be.
Thanks!

GoldLion

Hi again, I found which line I need to put the code in to get the ad in the right place. But I can't find the file in the hosting where I have to put the code. I also searched in the folder of brfinale222, but I can't find in the index or where to put the order with the ad. please help by guiding me. thanks

Kindred

Your theme's index.template.php
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

GoldLion

Thanks for the reply. However, something did not work out, I do not know why. Is it in the index of the main folder or in the index of the theme I use?

Speed King

Quote from: GoldLion on April 05, 2022, 06:15:53 AMThanks for the reply. However, something did not work out, I do not know why. Is it in the index of the main folder or in the index of the theme I use?

Make the changes in index.template.php file for all themes used. Do not make changes in index.php files, they are different.

Doug Heffernan

Quote from: GoldLion on April 05, 2022, 06:15:53 AMThanks for the reply. However, something did not work out, I do not know why. Is it in the index of the main folder or in the index of the theme I use?

You should edit the index.template.php file of the theme that you are using as default for your forum.

GoldLion

Thanks a lot to Speed King. He helped me put up the banner. But the position I want to be is the one I outlined in yellow.

Antechinus

Ok so just add the banner code after the linktree code in the template.

Code (Find) Select
// Custom banners and shoutboxes should be placed here, before the linktree.

// Show the navigation tree.
theme_linktree();
}
Code (Put your banner code where I have indicated) Select
// Custom banners and shoutboxes should be placed here, before the linktree.

// Show the navigation tree.
theme_linktree();

// Put your banner code here. :)

}

And yes, I know the default comment says to put it before the linktree, but really that's just personal preference. Putting it after the linktree is fine too.

Just make sure you get your syntax correct, or you will get a parse error. Keep a backup copy of the existing working template handy, in case you need to load that in a hurry. If you have any problems with the syntax, post your template here and ask for help. :)

GoldLion

Thank you so much Antechinus!!! It appeared exactly where I want it to be. Just one more question, here is the code I put in, but no matter how hard I try to center it, both as a photo and as a div, it doesn't want to stand in the center.
Would you tell me how to center it?

Code:

echo '
        <div class="banner">
<a href="https://........." target="_blank">
    <img src="http://...................../8.jpg"/>
</a>
</div>';

Doug Heffernan

Quote from: GoldLion on April 05, 2022, 05:36:10 PMCode:

echo '
        <div class="banner">
<a href="https://........." target="_blank">
    <img src="http://...................../8.jpg"/>
</a>
</div>';

Have you defined a banner class in the css? If you have you can center it by setting the value of margin-left and margin-right to auto and make it a block element. Like this:

.banner {
  margin-left: auto;
  margin-right: auto;
  display: block;
}

Or you can also use text-align: center; instead.

If you have not added a banner class to css, you can apply the text-align:center  property directly to the <div> tag.

I.e.

echo '
<div class="banner" style="text-align:center;">
<a href="https://........." target="_blank">
    <img src="http://...................../8.jpg"/>
</a>
</div>';

Antechinus

Oh dear, I am going to have to deliver another CSS spanking. :D

Quote from: Doug Heffernan on April 05, 2022, 05:59:04 PMHave you defined a banner class in the css? If you have you can center it by setting the value of margin-left and margin-right to auto and make it a block element. Like this:

.banner {
  margin-left: auto;
  margin-right: auto;
  display: block;
}
Sorry, Doug, that will not work. Two points.

First: all divs are always display: block; by default, because divs are a block level element. Defining a div as display: block; is a pointless waste of code.

Second, because divs are a block level element they are automatically full-width by default, which means the left and right margins are zero. So, setting those margins to auto will have no effect on the presentation.

Setting left and right margins to auto will only centre a div if the div is set to a restricted width, and that width is less than the parent element.

QuoteOr you can also use text-align: center; instead.
Yes. That will work, because images are not display: block; by default and can therefore be affected by the text-align property. If the image had been defined as display: block; (not usually necessary) then auto left and right margins would work on the image. Text-align does not work on block level elements.

GoldLion

Many thanks to Doug Heffernan and Antechinus!

Тhis is the code i used:
echo '
<div class="banner" style="text-align:center;">
<a href="https://........." target="_blank">
    <img src="http://...................../8.jpg"/>
</a>
</div>';


Be healthy! The topic is locking!  ;)


Advertisement: