Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By dani190 on
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
I believe this is where you
I believe this is where you need to set a new region ?
have a look at this explaination http://nicklewis.org/node/846
ok added a new region but im
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:
And in page.tpl.php i have
Any ideas why it isnt working?
Have you added any blocks to the banner region?
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.
you don't need a comma at
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.
Well as for banner region at
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
the parse error in
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
with this
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.
fixed now, um just 1 last
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?
anyone?
anyone?
If I understand correctly
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 orderThen in the css float the left sidebar "left" and boths the ads and right sidebar "right".
no its left
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
Think about what happens when you float right
When you have the order
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)