News:

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

Main Menu

Need to add banner code to Theme

Started by The Wizard, August 25, 2014, 10:31:30 AM

Previous topic - Next topic

The Wizard

Hello:

I am using SMF 2.0.8 and the Bright Forest theme - http://custom.simplemachines.org/themes/index.php?lemma=336

In the index.template.php I need to add my banner code after this line - // Custom banners and shoutboxes should be placed here, before the linktree.

Except in this theme this line does not exist. Does anyone know where I should add my banner code in this theme?

The Banner code I need to add in case you need to see -

// Monthly Banner code

global $sourcedir;

if (file_exists($sourcedir . '/banner/BannerRotation.php'))
{
require_once($sourcedir . '/banner/BannerRotation.php');
BannerRotation();
}



Thanks

Wiz





Suki

You can use $context['template_layers'] var to insert your banner on all themes:

Sources/Load.php:

After this:

$context['template_layers'] = array('html', 'body');

Add this:

if (file_exists($sourcedir . '/banner/BannerRotation.php'))
   {
         require_once($sourcedir . '/banner/BannerRotation.php');
         BannerRotation();
   }

array_splice($context['template_layers'], 2, 0, 'banner_rotation');

Of course this means BannerRotation() needs to follow SMF's template system, you need to create a new template file and put all your "view" code inside the function template_banner_rotation()  BannerRotation() needs to pass all the data to this template, preferable within a $context var.
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

The Wizard

Hello Suki:

I am looking for something simple as the bright forest theme is a older theme. My graphic artist wanted to go with a square theme, and has chosen this one so I'm stuck with it. I am unfamiliar with this style of theme and so any help would be appreciated.

Wiz 

Suki

With the proposed change you don't actually need to bother with any template edits...

But if you want to follow that path, atach your index.template file here.
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.


Suki

This si the menu stuff:


echo '
</div>
', template_menu(), '
<div id="content">';


Just put your code below that part.
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.


Advertisement: