Changing Sideblock Width

Changing Sideblock Width

by Edward Goytia -
Number of replies: 18

Simple question I hope.......

I've scanned through the CSS files to find the settings that control the width of the left and right sideblock widths but haven't been having any luck. I'm a newbie to Moolde but somewhat familiar with CSS. Can someone give me an idea of what setting I'm looking for? I assume they're being set by a pixel width but I don't see anything that looks like the right number or setting name.

Any help would be greatly appreciated. Thanks.

Average of ratings: -
In reply to Edward Goytia

Re: Changing Sideblock Width

by Chanfin David -
Sideblocks are within 2 cells of a table that are identified respectively by #left-column and #right-column.

<table>
....
   <td id="left-column">

     Left Sideblocks go here

   </td>
....
   <td id="right-column>

     Right Sideblocks goe here

   </td>
....
</table>


Look for these id in your theme's css files and add the width attribute there. If there is no definiton for theses id just create one :

#layout-table #left-column {
width: 100px;
}

Hope it helps...
David.
In reply to Chanfin David

Re: Changing Sideblock Width

by Edward Goytia -

Thanks for your response. Unfortunately I tried that but it doesn't seem to be working. Here is the content of my styles-layout.css:

#layout-table #left-column,
#layout-table #middle-column,
#layout-table #right-column
{
  vertical-align:top;
}

#layout-table #left-column {
  width: 250px;
}

#layout-table #middle-column {
  padding-left:12px;
  padding-right:12px;
}

#layout-table #right-column {
  width: 150px;
}

I'm using a modified HSU theme and thought these lines would be the fix but they don't have any effect. I've tried making them extra wide just for testing purposes but to no avail. Might there be another file elsewhere controlling this setting?

-Ed

In reply to Edward Goytia

Re: Changing Sideblock Width

by Joseph Rézeau -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators

Edward,

The column width has probably already been defined in one of your CSS files. Just add the !important parameter to override its definition.

I have tested this with the standard theme and it works.

#layout-table #right-column {
  width: 150px!important;
}

Hope that helps,

Joseph

In reply to Joseph Rézeau

Re: Changing Sideblock Width

by Edward Goytia -

Thanks. Tried it but still has no effect. I've tried scanning through all of the CSS files in the theme but can't find any other place that would control the setting. Nothing I do to #layout-table #righ-column or #layout-table #left-column seems to make any difference. Any other suggestions?

I may just have to switch to a different theme. I did find another bug where the HTML edit window in the default posting view for a forum doesn't provide any space for entering text. The only way to do so is enlarge the editor. The theme may simply be "broken" (if that's possible) in a way I just don't know how to fix just yet.

Thanks for your help.

In reply to Edward Goytia

Re: Changing Sideblock Width

by Joseph Rézeau -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators
Edward.
You never said which theme you are actualy using. Is it one of the themes in the standard Moodle distribution? or a "customized" theme? Which version of Moodle are you using?
Have you remembered to refresh (Ctrl-F5) your browser for changes to take effect?
Joseph
In reply to Joseph Rézeau

Re: Changing Sideblock Width

by Edward Goytia -

Moodle 1.5.3 typical installation with nothing special added. Running on Windows server device internally with Apache and MySQL in the out-of-the-box configuration that comes with Moodle. I'm a newbie and so I'm ramping up somewhat at a pace.

I've definitely been remembering to refresh the browser. In fact I've been exiting IE altogether. At times, I've stopped and started the entire site. Still to no avail.

The issue began as I was trying to update the "standard_hsu_ForMAC" theme which is a modification of the "formal_white" theme. I believe this is by those great folks at HSU. Anyway, the issue seemed to grow to be something beyond just this theme anyway. It seems so matter which one I try to modify, even the standard theme, nothing seems to make any difference in the width of the side blocks.

I provided the text for the form of my edits in an earlier post. Nothing seems wrong to me in the syntax of the edits but I have to admit I'm not a CSS expert so something may just not be apparent to me.

Any ideas regarding what I might be missing or how I could best force an width change to test the problem. My thinking is that something else in the CSS structure is forcing the sideblock width to remain within certain boundaries and trying to make it wider comes up against that limit. When looking around at other sites I've yet to see one with a width any greater than the standard.

Thanks for your help.

In reply to Joseph Rézeau

Re: Changing Sideblock Width

by Edward Goytia -

And the answer is...........

I found the answer accidentally by reading a post from another thread. index.php in the main moodle folder defines block_width limits in this fashion right at the top of the file:

/// Bounds for block widths on this page
define('BLOCK_L_MIN_WIDTH', 160);
define('BLOCK_L_MAX_WIDTH', 210);
define('BLOCK_R_MIN_WIDTH', 160);
define('BLOCK_R_MAX_WIDTH', 210);

If I change those then the pages reflect the new widths. So what must have been happening is that my attempts in the CSS were larger than the max_width set in the index.php. That was the limitation. 

In reply to Edward Goytia

Re: Changing Sideblock Width

by Joseph Rézeau -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators

Hi Edward,

This is an interesting finding. approve

Actually, the min. and max. sizes of the left and right blocks are set at more than one place in Moodle's core code. They are set in all of the following.

c:\moodle\www\moodle16beta\moodle\course\format\topics\format.php
c:\moodle\www\moodle16beta\moodle\course\format\lams\format.php
c:\moodle\www\moodle16beta\moodle\course\format\weeks\format.php
c:\moodle\www\moodle16beta\moodle\blog\header.php
c:\moodle\www\moodle16beta\moodle\index.php
c:\moodle\www\moodle16beta\moodle\course\format\scorm\format.php
c:\moodle\www\moodle16beta\moodle\blocks\pagedemo.php
c:\moodle\www\moodle16beta\moodle\course\format\social\format.php

However, I maintain that you can over-ride the blocks' max size in a CSS file of the theme you are using, by adding these lines:

#layout-table #left-column {width: 500px!important;}
#layout-table #right-column {width: 500px!important;}

You can set width at any required size (500px in my example), even exceeding the set MAX_WIDTH parameter in the php files, it will work.

Whether you decide to go the CSS way or hack the PHP files depends on the final result you want to achieve.

Going the CSS way

You can fix the #layout-table #left-column or #right-column width throught your site or course, and this fixed width will be determined by your actual THEME.

Hacking the PHP code

You can change the BLOCK_L or BLOCK_R MIN or MAX values to achieve a result which will be dependent upon the actual contents of the blocks. The way I expect this to work is that e.g. if the "title" of one of your blocks is a character string of a certain length, the width of the column containing that block will be able to grow or shrink according to such string length (within the bounds you'll have set in the various php files listed above) or if one of your blocks contains an image of a certain width, etc. However, it does not work like this. If you put in a block an image whose width exceeds the BLOCK_R_MAX_WIDTH limit, the column will still grow in order to display the full image...

Now that we've got all the elements, you can experiment and hopefully achieve the desired result.smile

Joseph

In reply to Joseph Rézeau

Re: Changing Sideblock Width

by Edward Goytia -

Well I'll keep trying to see how to get it to work the way you've indicated. I even just copied the text from your post, refreshed the browser, stopped and started it, stopped and started the server and still no change. Something's not right.

Thanks for your help.

In reply to Edward Goytia

Re: Changing Sideblock Width

by Julian Ridden -

Are you using IE? It's cacheing of .css files is painful at best.

After making changes to your stylesheets, be sure to do a full refresh by holding down the Ctrl key as you click the refresh button.

In reply to Julian Ridden

Re: Changing Sideblock Width

by Leo Dil -
I'm having the same problem here. I use 1.9.8+

With
#layout-table #left-column {
width: 100px;
}

I'm not able to change anything, but if I change .sideblock then it works.

The only problem is with the tables width. For example if you go to Users-->Accounts-->Browse list of users the table is biger that the max-width of the entire moodle #Page

I use a layout of 960px width aligned middle.

Is there any tip on how to solve this porblem?

Thanks
In reply to Leo Dil

Re: Changing Sideblock Width

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers
Hi Leo,

More often than not I tend to set my page width to 95%, and layout-table to 100%.

#page {width: 95%; margin: 0 auto; padding: 0;}

#layout-table { width: 100%;}


Sideblocks are best left alone so that they use standard layout with alters depending on the page you happen to be on.

If you do want to set sideblocks with fixed width, say 210px then you can but you will run into problems in different page views.

.sideblock { width: 210px;}

Mary
In reply to Mary Evans

Re: Changing Sideblock Width

by Vijay N -
On a similar CSS enquiry does any one know how to set the Language menu bar on the header of the theme? When I set up the KCS theme, the language menu disappeared from all pages. To test if it works on other themes I changed the theme and it came back so I know its KCS theme that creates the problem. The only page that had the language menu for the default index.php (the page u get when entering the wrong login details).

Can any one tell me the code for setting this up on the header.html file. Thanks.

In reply to Vijay N

Re: Changing Sideblock Width

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers
Hi Vijay

You will find the code in header.html in standard theme...but to give you an idea what to look for here is the code...

<div class="headermenu"><?php echo $menu ?></div>


You can find the CSS in styles_layout.css in standard theme
.headermenu {
float:right;
text-align:right;
}

Mary
In reply to Mary Evans

Re: Changing Sideblock Width

by Vijay N -

HI Mary,

I did as you suggest but now the problem is that although I got the language bar back it also displays teh "logged in" menu. I don't want the "logged in" information because I already have that running.

In reply to Vijay N

Re: Changing Sideblock Width

by Vijay N -
Ok now there is another problem again. The language bar will not appear in any other page other than the front page. Only the "logged in" information appears and not the language bar. I know you need to specify the code in 2 sections on the header.html file. One is the place where it say (This page will be on front page only) and one on the other area og header.html where it is commented as (this will appear is every other page).
In reply to Mary Evans

Re: Changing Sideblock Width

by Leo Dil -
Hi Mary,

I had changed the sideblock, but I found another solution. I need a 300px width block in a course-view only, so I'm gona change it there and leave the rest as is.

Thanks for the tips and happy Moodle-ing
In reply to Joseph Rézeau

Re: Changing Sideblock Width

by Gustavo Díaz Jaimes -

Thank U, i find the way to change it

In moodle 1.9 you can see

file: index.php

...

// Bounds for block widths
// more flexible for theme designers taken from theme config.php
$lmin = (empty($THEME->block_l_min_width)) ? 100 : $THEME->block_l_min_width;
$lmax = (empty($THEME->block_l_max_width)) ? 210 : $THEME->block_l_max_width;
$rmin = (empty($THEME->block_r_min_width)) ? 100 : $THEME->block_r_min_width;
$rmax = (empty($THEME->block_r_max_width)) ? 210 : $THEME->block_r_max_width;

...

So I add

file theme/my_theme/config.php

...

$THEME->block_l_min_width = 210;
$THEME->block_l_max_width = 210;
$THEME->block_r_min_width = 210;
$THEME->block_r_max_width = 210;