Hello, im a currentlly developing a drupal theme and need some help. I am using a container to put the left side bar, content, and the right side bar in. When i try to add in another sidebar to act as ads on the right, it wont show up...

Bellow i have included some code were i insert the colums.

CSS code:

#container {
}
#container #left {
	width:120px;
	float:left;
	background:#e4e4e4;
	padding:10px;	
}
#container #ad {
	width:290px;
	padding:10px;	
	margin 0px 160px 0px 540px;
	background:#e4e4e4;
}
#container #right {
	width:150px;
	float:right;
	background:#e4e4e4;
	padding:10px;
}
#container #content {
	margin:0px 410px 0px 120px;
}

Now the width is 1000 for now.

The page.tpl.php code:

<div id="container">

<?php if ($sidebar_left != ""): ?>
<div id="left"><?php print $sidebar_left ?></div>
<?php endif; ?>

<?php if ($sidebar_ad != ""): ?>
<div id="ad"><?php print $sidebar_ad ?></div>
<?php endif; ?>

<?php if ($sidebar_right != ""): ?>
<div id="right"><?php print $sidebar_right ?></div>
<?php endif; ?>

<div id="content">
<?php if ($title) { ?><h1><?php print $title ?></h1><?php } ?>
<div id="tabs"><?php print $tabs ?></div>
<?php print $help ?>
<?php print $messages ?>
<?php print $content; ?>
</div></div>

Now as you see i have 4 colums set. Now at the moment only sidebar_left, content, and sidebar_right show

Sidebar_ad will not show

Any ideas guys??

Thanks

Comments

VM’s picture

I believe this is where you need to set a new region ?

have a look at this explaination http://nicklewis.org/node/846

dani190’s picture

ok added a new region but im getting this error whenever i try to visit my site

Parse error: parse error, unexpected T_STRING in /dani/drupal/themes/america/template.php on line 2

In template.php i have the following code:

<?php
function america_regions() {
  return array(
		 'left' => t('left sidebar'),
    'right' => t('right sidebar'),
    'content' => t('content'),
    'header' => t('header'),
    'footer' => t('footer'),
    'banner' => t('banner'),
  );
}
?>

And in page.tpl.php i have

<?php if ($banner != ""): ?>
<div id="banner"><?php print $banner ?></div>
<?php endif; ?>

Any ideas why it isnt working?

nevets’s picture

Have you added any blocks to the banner region? If not, you will not get the fourth column.

As for the error, that is likely causing you problems. I can not see anything visually so I wonder if you have managed to type a control character in there.

VM’s picture

you don't need a comma at the end of this line 'banner' => t('banner'),

there is nothing coming next. thus a comma is unnecessary.

dani190’s picture

Well as for banner region at this point i dont know what that is, and cant even access my site because of this error, but also i copied and pasted the code from the tutorial perty much so i dont know what would of gone wronge

VM’s picture

the parse error in template.php is because there is an extra comma. if you look at the examples on that tutorial. the last section doesnt have a comma.

in template.php

replace

<?php
function america_regions() {
  return array(
         'left' => t('left sidebar'),
    'right' => t('right sidebar'),
    'content' => t('content'),
    'header' => t('header'),
    'footer' => t('footer'),
    'banner' => t('banner'),
  );
}
?>

with this

<?php
function america_regions() {
  return array(
         'left' => t('left sidebar'),
    'right' => t('right sidebar'),
    'content' => t('content'),
    'header' => t('header'),
    'footer' => t('footer'),
    'banner' => t('banner')
  );
}
?>

the banner region would only need a comma after it, if there was another region after it. its the last region and therefore does not need a comma.

dani190’s picture

fixed now, um just 1 last issue if i have sidebar right using float:right and i want banner to show up to the left of it, how can i enter that into the css code so it stays to sidebars right at all times and is lined up?

dani190’s picture

anyone?

nevets’s picture

If I understand correctly you want things to appear across the page in the order leftside bar | content | ads | right sidebar. If this is correct then in your page.tpl.php place them in the order

left sidebar
right sidebar
ads
content

Then in the css float the left sidebar "left" and boths the ads and right sidebar "right".

dani190’s picture

no its

left sidebar
content
ads
right sidebar

and i have leftside bar float:left and ads and right side bar float:right, but the ads end up being on the far right insted of beside the content

nevets’s picture

When you have the order

left sidebar
content
ads
right sidebar

It moves the left sidebar left, the the ads right (all the way right), then the right sidebar right (till they bump up against the ads). So it you want the ads to the left of the right sidebar the need to appear in page.tpl.php after the right sidebar. (I think you may find the content needs to be last or the ads will be below the content)