New banner position (Middle)

Modules, Add-ons and custom code that's more than just a quick hack or Mod.
Post Reply
Painstik
Posts: 122
Joined: Sun Jul 19, 2009 1:19 pm
Location: Croatia

New banner position (Middle)

Post by Painstik »

This is a custom code for those who wants a new banner position (isntead only Top of page, and Bottom of page) Middle of page.

I made this to show new banner position on Homepage between Featured products and New products.



Open: language/en/admin/banners.ini
Add:

Code: Select all

MiddleOfPage = "Middle of Page"
BannerMiddleOfPage = "Middle of Page"

Open: admin/includes/classes/class.banners.php
Find:

Code: Select all

				if ($banner['location'] == "top") {
					$GLOBALS['Location'] .= sprintf(" (%s)", GetLang('BannerTopOfPage'));
				}
				else {
					$GLOBALS['Location'] .= sprintf(" (%s)", GetLang('BannerBottomOfPage'));
				}
Replace with:

Code: Select all

				switch ($banner['location']) {
					case "top": {
					$GLOBALS['Location'] .= sprintf(" (%s)", GetLang('BannerTopOfPage'));
					break;
				}
					case "middle": {
					$GLOBALS['Location'] .= sprintf(" (%s)", GetLang('BannerMiddleOfPage'));
					break;
				}
					case "bottom": {
					$GLOBALS['Location'] .= sprintf(" (%s)", GetLang('BannerBottomOfPage'));
					break;
					}
				}
Find:

Code: Select all

					if ($banner['location'] == "top") {
						$GLOBALS['IsLocationTop'] = "selected=\"selected\"";
					}
Add after:

Code: Select all

					else if ($banner['location'] == "middle") {
						$GLOBALS['IsLocationMiddle'] = "selected=\"selected\"";
					}

Open: includes/classes/class.banner.php
Find:

Code: Select all

							case "home_page":
							case "search_page": {
								if($banner['location'] == "top" && !isset($GLOBALS['Banners']['top'])) {
									$GLOBALS['Banners']['top'] = $banner;
								}
Add after:

Code: Select all

								else if($banner['location'] == "middle" && !isset($GLOBALS['Banners']['middle'])) {
									$GLOBALS['Banners']['middle'] = $banner;
								}
Find:

Code: Select all

							case "brand_page":
							case "category_page": {
								if($banner['location'] == "top" && !isset($GLOBALS['Banners'][$banner['catorbrandid']]['top'])) {
									$GLOBALS['Banners'][$banner['catorbrandid']]['top'] = $banner;
								}
Add after:

Code: Select all

								else if($banner['location'] == "middle" && !isset($GLOBALS['Banners'][$banner['catorbrandid']]['middle'])) {
									$GLOBALS['Banners'][$banner['catorbrandid']]['middle'] = $banner;
								}

Open: lib/templates/template.php
Find:

Code: Select all

					case "home_page":
					case "search_page": {
						// Is there a top template?
						if(isset($GLOBALS["Banners"]["top"])) {
							// Replace it out
							$tplData = str_replace("%%Banner.TopBanner%%", $GLOBALS["Banners"]["top"]["content"], $tplData);
						}
						else {
							// Replace it with nothing
							$tplData = str_replace("%%Banner.TopBanner%%", "", $tplData);
						}
Add after:

Code: Select all

						// Is there a middle template?
						if(isset($GLOBALS["Banners"]["middle"])) {
							// Replace it out
							$tplData = str_replace("%%Banner.MiddleBanner%%", $GLOBALS["Banners"]["middle"]["content"], $tplData);
						}
						else {
							// Replace it with nothing
							$tplData = str_replace("%%Banner.MiddleBanner%%", "", $tplData);
						}
Find:

Code: Select all

						if(isset($GLOBALS["Banners"][$id])) {
							// Is there a top template?
							if(isset($GLOBALS["Banners"][$id]["top"])) {
								// Replace it out
								$tplData = str_replace("%%Banner.TopBanner%%", $GLOBALS["Banners"][$id]["top"]["content"], $tplData);
							}
							else {
								// Replace it with nothing
								$tplData = str_replace("%%Banner.TopBanner%%", "", $tplData);
							}
Add after:

Code: Select all

							// Is there a middle template?
							if(isset($GLOBALS["Banners"]["middle"])) {
								// Replace it out
								$tplData = str_replace("%%Banner.MiddleBanner%%", $GLOBALS["Banners"]["middle"]["content"], $tplData);
							}
							else {
								// Replace it with nothing
								$tplData = str_replace("%%Banner.MiddleBanner%%", "", $tplData);
							}
Find:

Code: Select all

							// Replace the banners with nothing
							$tplData = str_replace("%%Banner.TopBanner%%", "", $tplData);
Add after:

Code: Select all

							$tplData = str_replace("%%Banner.MiddleBanner%%", "", $tplData);
Do this twice, the lines are one after other.


Open: admin/templates/banner.form.tpl
Find:

Code: Select all

						<select name="bannerloc" id="bannerloc" class="Field150">
							<option value="">%%LNG_ChooseALocation%%</option>
							<option value="top" %%GLOBAL_IsLocationTop%%>%%LNG_TopOfPage%%</option>
Add after:

Code: Select all

							<option value="middle" %%GLOBAL_IsLocationMiddle%%>%%LNG_MiddleOfPage%%</option>

Open: templates/[YOUR_TEMPLATE_NAME]/default.html
Find:

Code: Select all

		<div class="Content" id="LayoutColumn2">
			%%Banner.TopBanner%%
			%%Panel.HomeFeaturedProducts%%
Add after:

Code: Select all

			%%Banner.MiddleBanner%%

All code is set now, just one more modification in database.
You can make SQL query:

Code: Select all

ALTER TABLE `isc_banners` CHANGE `location` `location` ENUM( 'top', 'middle', 'bottom' ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'top' 
or open phpMyAdmin, select table isc_banners, and edit field location.
You allready have a value there

Code: Select all

'top', 'bottom'
All you have to do is add a new value

Code: Select all

'top', 'middle', 'bottom'
And that is all.

Note: This Middle poisition will work only on homepage as we set it in default.html. In order to work on other pages (category, brand & search results pages) you need to add %%Banner.MiddleBanner%% in your template html files (category.html, brands.html & search.html)
Need custom coding for Interspire Shopping Cart? Contact me
karl800
Posts: 35
Joined: Sat Oct 03, 2009 8:43 pm
Location: Staffordshire, UK

Re: New banner position (Middle)

Post by karl800 »

Could this work the same way as a side banner instead of keep going into the backend and editing the html and creating a sepeatate page.

This way would work all in the admin.

Please let me know.
Thanks
Karl
Painstik
Posts: 122
Joined: Sun Jul 19, 2009 1:19 pm
Location: Croatia

Re: New banner position (Middle)

Post by Painstik »

You can put wherever you want %%Banner.MiddleBanner%%
Need custom coding for Interspire Shopping Cart? Contact me
Tony Barnes
Posts: 744
Joined: Thu Jun 18, 2009 8:59 am

Re: New banner position (Middle)

Post by Tony Barnes »

Nice detailed mod

There are plenty of folk who will use this I think, as above, a side variant will be excellent, they just need to make the banner the right size
getrules
Posts: 1
Joined: Wed Jun 09, 2010 9:46 pm

Re: New banner position (Middle)

Post by getrules »

This hack is incredible! very easy to implemente if you understand a little of the php semantics. I've added right and left banners as well and it all works perfectly. big thumbs up!
CharlieFoxtrot
Confirmed
Confirmed
Posts: 413
Joined: Sun Aug 09, 2009 1:23 pm

Re: New banner position (Middle)

Post by CharlieFoxtrot »

Nice!! ::thumbsup::
ISC 4.0.7

"... and let's be honest that whole "by design" thing is getting old too."
sahil
Posts: 1
Joined: Sat Jul 10, 2010 8:39 pm

Re: New banner position (Middle)

Post by sahil »

Can u please tell me what to wrie if i want left and right banners as well. Shall i just replace the "Middle" with "LeftSide" and "RightSide"

Mod Note: Don't shout... It's annoying and rude...
vikram
Posts: 3
Joined: Sat Aug 06, 2011 12:27 pm
Location: india

Re: New banner position (Middle)

Post by vikram »

Hello,

This post is very helpfull for me and its working fine................


Thanks for such a great post. Keep posting such a helpful post for interspire


Thanks
vikram singh rathore
rsg
Posts: 7
Joined: Sat Nov 10, 2012 10:56 pm
Location: London

Re: New banner position (Middle)

Post by rsg »

I hope it's not a problem if I bump this thread up.

I've been tearing my hair out trying to figure out how to display a banner on top of every product page that is unique to the product and/or category it is in. For example, if I set a category banner, I could use the same banner for the product pages too.

I've modified the above code as much as I can but cannot figure out how to pull the product options into a dropdown menu in the banner creation page in the admin section.

Is anyone out there willing to help me? I'm willing to pay for the mod.

Thanks.
Post Reply