Banner spot in template
Banner spot in template
We have a banner spot that is in the template of the web site. We'd like this banner to be different than the default (what it is currently) for 3 of the pages on our site. What's the easiest way to accomplish this?
Re: Banner spot in template
I don't get your point completely. Are you saying you want different banners on the three different pages, or do you want the banners to rotate over the three pages, or do you want a specific banner on every page.
Ronny
Ronny
Re: Banner spot in template
Create a different template for this 3 pages ...ITistic wrote: We'd like this banner to be different than the default (what it is currently) for 3 of the pages on our site. What's the easiest way to accomplish this?
Re: Banner spot in template
If you want a specific image on every page, say banner1 on page1, banner2 on page2 etc..., you don't need banner (as a module),
You can go with:
Create a UDT to get the page you're on, name it "get_root_page_alias":
Place the calling of a UDT in the template:
Create a container in the template where the banner should occur:
In the CSS, style a DIV for every specific page, with the corresponding image:
This way depending on the page you're at, a different container, with a different image, specific for that page is being pulled.
Ronny
You can go with:
Create a UDT to get the page you're on, name it "get_root_page_alias":
Code: Select all
global $gCms;
global $smarty;
$manager =& $gCms->GetHierarchyManager();
$var = 'root_page_alias';
if( isset($params['assign']) && $params['assign'] != '' )
{
$var = $params['assign'];
}
$result = "NO RESULT";
$thisPage = $gCms->variables['content_id'];
$currentNode = &$manager->sureGetNodeById($thisPage);
while( isset($currentNode) && $currentNode->getLevel() >= 0 )
{
$currentContent =& $currentNode->getContent();
$result = $currentContent->Alias();
$currentNode =& $currentNode->getParentNode();
}
$smarty->assign($var,$result);
Code: Select all
{get_root_page_alias assign="mainpage"}
Code: Select all
<div id="{$mainpage}">
</div>
Code: Select all
div#page1 {
/* you can set your own image here */
margin-left: 28%; /* set image similar position */
background: #FFFFFF url(images/banner1.jpg) no-repeat 12px 12px;
height: 190px; /* adjust according your image size */
}
div#page2 {
/* you can set your own image here */
margin-left: 28%; /* set image similar position */
background: #FFFFFF url(images/banner2.jpg) no-repeat 12px 12px;
height: 190px; /* adjust according your image size */
}
Ronny
Re: Banner spot in template
Thanks for the reply, everyone.
RonnyK -- Your method would work except for the fact the banner also needs to be a link to a specific URL. To explain further, what we have now is Google AdSense in this banner spot on the *entire* site. We now have a vendor who has purchased this banner spot on 3 different pages of our site, so on these 3 pages we have to replace the Google AdSense code in this particular spot with the vendor's banner and link.
The site already has 4 different templates which all are a little unique so I'd rather not create 4 more just for this banner. Seems as though there is a better way to handle this. Is there a way for me to use PHP to determine the page and write out specific code if it's one of these 3 pages in question, and if not write out the AdSense code? Maybe this would be the best option.
RonnyK -- Your method would work except for the fact the banner also needs to be a link to a specific URL. To explain further, what we have now is Google AdSense in this banner spot on the *entire* site. We now have a vendor who has purchased this banner spot on 3 different pages of our site, so on these 3 pages we have to replace the Google AdSense code in this particular spot with the vendor's banner and link.
The site already has 4 different templates which all are a little unique so I'd rather not create 4 more just for this banner. Seems as though there is a better way to handle this. Is there a way for me to use PHP to determine the page and write out specific code if it's one of these 3 pages in question, and if not write out the AdSense code? Maybe this would be the best option.
-
- Support Guru
- Posts: 8169
- Joined: Tue Oct 19, 2004 6:44 pm
Re: Banner spot in template
try something like this in your template:
Code: Select all
{if $page_alias == 'page1'}
<!-- google addsense code -->
{elseif $page_alias == 'page2'}
<a href="http://www.domain.com"><img src="blah.jpg"/></a>
{elseif $page_alias == 'page3' or $page_alias == 'page4}
<a href="http://www.domain.com"><img src="blah.jpg"/></a>
{/fi}
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.