Banner spot in template

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Post Reply
ITistic
Forum Members
Forum Members
Posts: 25
Joined: Tue Jun 27, 2006 9:28 pm

Banner spot in template

Post by ITistic »

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?
RonnyK
Support Guru
Support Guru
Posts: 4962
Joined: Wed Oct 25, 2006 8:29 pm

Re: Banner spot in template

Post by RonnyK »

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
cyberman

Re: Banner spot in template

Post by cyberman »

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?
Create a different template for this 3 pages ...
RonnyK
Support Guru
Support Guru
Posts: 4962
Joined: Wed Oct 25, 2006 8:29 pm

Re: Banner spot in template

Post by RonnyK »

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":

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);
Place the calling of a UDT in the template:

Code: Select all

{get_root_page_alias assign="mainpage"}
Create a container in the template where the banner should occur:

Code: Select all

   <div id="{$mainpage}">
   </div>  
In the CSS, style a DIV for every specific page, with the corresponding image:

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 */
}
This way depending on the page you're at, a different container, with a different image, specific for that page is being pulled.

Ronny
ITistic
Forum Members
Forum Members
Posts: 25
Joined: Tue Jun 27, 2006 9:28 pm

Re: Banner spot in template

Post by ITistic »

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.
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: Banner spot in template

Post by calguy1000 »

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.
Post Reply

Return to “CMSMS Core”