Bootstrap Themes

Bootstrap Themes

by John Banner -
Number of replies: 14

Looking at Moodle going forward I see that the most themes are now bootstrap based and the others have been basically removed from core in 2.7

Can Moodle HQ look into adding into the custom settings for the bootstrap themes to easily resize the columns?

Right now, almost all the themes that are based on bootstrap have REALLY wide columns, like almost 25-30% of the screen/page is dedicated to a column. The headings and activity names are also really huge but I have managed to add in the custom css of the theme to change those. If we use 3 columns in a course, which most are, then the course content, the main content, only gets 40% of the screen. The column widths are using up valuable course space. Our teachers like blocks so moving to 2 column only is not an option.

I am not a theme designer so I do not even know where to begin to fix this for us, currently using non bootstrap theme in Moodle 2.4 since upgrading would mean the eventual adaptation of a bootstrap theme.

So how can one easily, without allot of LESS or knowledge change these column widths in the custom CSS setting for the theme?

Thanks,

John

Average of ratings: -
In reply to John Banner

Re: Bootstrap Themes

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

Hi John,

Moodle 2.5, 2.6 and 2.7 core bootstrap is version 2.3.2 which implements a grid system.  This is based on classes with percentages defined for different screen sizes in order to implement responsiveness.  You can find details of the system here: http://getbootstrap.com/2.3.2/scaffolding.html.

To solve the course content issue you could change the layout to be a two column one by editing the 'config.php' file of the theme, finding the 'course' layout and changing the file from 'columns3.php' to 'columns2.php' - even though the teachers do not like it, perhaps if they tried it for a while then they would get over the shock of change.  Another alternative is to enable docking, which is available in M2.7 and should be back ported to M2.6 (if not already).

In my experience, reducing the block region column space below '3' as currently set in the layout files is problematic leading to text overflowing.  I don't think changing in the custom CSS is viable as there is also JavaScript that manipulates the use of these classes on the block regions and content.

Cheers,

Gareth

In reply to Gareth J Barnard

Re: Bootstrap Themes

by John Banner -

Our Faculty would not use the dock, if they would it would be great. We already get so many call because they clicked the send to dock in the block and do not grasp the concept of the dock and forget that it is even there or do not even notice that it is there.

I tried changing the span in the layout.php for 3 column on side-pre and side-post to span2 and when viewing the page the left Blocks, main menu, look great, perfectly sized and smaller. The right block, the additional blocks, are still the same size, gigantic with so much white space.

Why did only the left blocks change to the correct size? Ho can I get the right blocks to match the same size as the left?

Thanks,

John

In reply to John Banner

Re: Bootstrap Themes

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

What bootstrap theme are you modifying and what version of Moodle?  Are you experimenting with Bas's contributed Bootstrap for M2.4?

As well as altering the block regions, you have to alter the content too.  The entire row must add up to 12 as stated on the 'getbootstrap.com' link above.

In reply to Gareth J Barnard

Re: Bootstrap Themes

by John Banner -

No, I have Moodle 2.6 running in XAMMP as localhost, so "Clean" theme. This would be our next upgrade path ( we always stay 1 version behind ) so I like to get in and see what has changed so I can make a "What's New" PDF for our Faculty and Staff so they are aware of the changes.

I believe I am getting different sized columns because the left blocks ( Main Navigation Blocks ) are included in the same region or DIV as the course content (region-main) and the right blocks are outside of that region so the percentages for each block, left and right, will be different.

 

Thanks,

John

In reply to Gareth J Barnard

Re: Bootstrap Themes

by John Banner -

I kinda got it! What would cause the button to do this? I had to pull the left blocks ( Main Navigation Blocks) out of the same region as the course content to make it work but Button?

In reply to John Banner

Re: Bootstrap Themes

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

Hi John,

If you are using Clean theme in Moodle 2.5, or 2.6 then you would need to change the following to make it into a 2 column for course and incourse pages...

$THEME->layouts = array(
    // Most backwards compatible layout without the blocks - this is the layout used by default.
    'base' => array(
        'file' => 'columns1.php',
        'regions' => array(),
    ),
    // Standard layout with blocks, this is recommended for most pages with general information.
    'standard' => array(
        'file' => 'columns3.php',
        'regions' => array('side-pre', 'side-post'),
        'defaultregion' => 'side-pre',
    ),
    // Main course page.
    'course' => array(
        'file' => 'columns2.php',
        'regions' => array('side-pre'),
        'defaultregion' => 'side-pre',
        'options' => array('langmenu' => true),
    ),
    'coursecategory' => array(
        'file' => 'columns3.php',
        'regions' => array('side-pre', 'side-post'),
        'defaultregion' => 'side-pre',
    ),
    // Part of course, typical for modules - default page layout if $cm specified in require_login().
    'incourse' => array(
        'file' => 'columns2.php',
        'regions' => array('side-pre'),
        'defaultregion' => 'side-pre',
    ),
    // The site home page.
    'frontpage' => array(
        'file' => 'columns3.php',
        'regions' => array('side-pre', 'side-post'),
        'defaultregion' => 'side-pre',
        'options' => array('nonavbar' => true),
    ),
    // Server administration scripts.
    'admin' => array(
        'file' => 'columns2.php',
        'regions' => array('side-pre'),
        'defaultregion' => 'side-pre',
    ),
    // My dashboard page.
    'mydashboard' => array(
        'file' => 'columns3.php',
        'regions' => array('side-pre', 'side-post'),
        'defaultregion' => 'side-pre',
        'options' => array('langmenu' => true),
    ),
    // My public page.
    'mypublic' => array(
        'file' => 'columns3.php',
        'regions' => array('side-pre', 'side-post'),
        'defaultregion' => 'side-pre',
    ),
    'login' => array(
        'file' => 'columns1.php',
        'regions' => array(),
        'options' => array('langmenu' => true),
    ),

    // Pages that appear in pop-up windows - no navigation, no blocks, no header.
    'popup' => array(
        'file' => 'popup.php',
        'regions' => array(),
        'options' => array('nofooter' => true, 'nonavbar' => true),
    ),
    // No blocks and minimal footer - used for legacy frame layouts only!
    'frametop' => array(
        'file' => 'columns1.php',
        'regions' => array(),
        'options' => array('nofooter' => true, 'nocoursefooter' => true),
    ),
    // Embeded pages, like iframe/object embeded in moodleform - it needs as much space as possible.
    'embedded' => array(
        'file' => 'embedded.php',
        'regions' => array()
    ),
    // Used during upgrade and install, and for the 'This site is undergoing maintenance' message.
    // This must not have any blocks, links, or API calls that would lead to database or cache interaction.
    // Please be extremely careful if you are modifying this layout.
    'maintenance' => array(
        'file' => 'maintenance.php',
        'regions' => array(),
    ),
    // Should display the content and basic headers only.
    'print' => array(
        'file' => 'columns1.php',
        'regions' => array(),
        'options' => array('nofooter' => true, 'nonavbar' => false),
    ),
    // The pagelayout used when a redirection is occuring.
    'redirect' => array(
        'file' => 'embedded.php',
        'regions' => array(),
    ),
    // The pagelayout used for reports.
    'report' => array(
        'file' => 'columns2.php',
        'regions' => array('side-pre'),
        'defaultregion' => 'side-pre',
    ),
    // The pagelayout used for safebrowser and securewindow.
    'secure' => array(
        'file' => 'secure.php',
        'regions' => array('side-pre', 'side-post'),
        'defaultregion' => 'side-pre'
    ),
);

Average of ratings: Useful (2)
In reply to Mary Evans

Re: Bootstrap Themes

by John Banner -

Wow, that was allot of content! Thanks for the information, if we cannot get the 3 column widths appropriately sized then this will be the route.

We are actually using your theme! PostIt Note in Moodle 2.4, I am actually trying to get the bootstrap based theme "Clean" to have the same column widths as in your theme. Since it is no longer maintained we will eventually have to go to a bootstrap theme down the road. The current "Clean" theme just has to wide of columns and your theme seems to be the perfect width so I was trying to match those widths.

Thanks!

John

In reply to John Banner

Re: Bootstrap Themes

by John Banner -

Thanks to everyone's input and a little reading on my part, I was able to get it down to about 20, 60, 20. I went through the navigation and everything seems to fit perfectly without wrapping.

Here is the finished work.

In reply to John Banner

Re: Bootstrap Themes

by Nick Varney -

John,

I am with you entirely on this thread. I too want to adopt a bootstrap-based theme but for the same reasons you've outlined I am very reluctant to deploy one with what I consider to be disproportionately large left and right columns leaving not enough screen estate for the main course content.

How did you achieve the results above and are they sustainable? i.e. is your theme going to be easy to maintain when bootstrap gets updated?

Nick

In reply to Nick Varney

Re: Bootstrap Themes

by John Banner -

I am in no way a theme designer, I just wanted more course content. I am still adjusting items as I go, in the end I am going to have to create a new theme by copying "clean" and renaming all the appropriate files and folders as soon as I search the forums on the how-to.

I basically went into the "clean" layouts folder, columns3.php and moved each content or block into their own region, the original 3 column layout had the left blocks and course content in the same region, I then used the custom css setting to adjust the widths using percentages.

Now looks like,

<div id="page-content" class="row-fluid">
        <div id="<?php echo $regionbsid ?>" class="span12">
              <div class="row-fluid">
                    <?php echo $OUTPUT->blocks('side-pre', 'span3 desktop-first-column'); ?>
                           <section id="region-main" class="span6 pull-left">
                                 <?php
                                          echo $OUTPUT->course_content_header();
                                          echo $OUTPUT->main_content();
                                          echo $OUTPUT->course_content_footer();
                                  ?>
                            </section>

                     <?php echo $OUTPUT->blocks('side-post', 'span3'); ?>

               </div>
        </div>

Custom CSS in the theme settings in Moodle:

.row-fluid .span6 {
width: 58.717948717948715%;
}

.row-fluid .span3 {
width: 18.076923076923077%;
}

body {
font-size: 12px;
}

h3 {
font-size: 18px;
}

It looks promising. The only issue I see now is that when using a non-desktop monitor like a mobile device the content gets screwed. I will eventually just use "clean" as the mobile theme after I create a new theme out of this one, (need to figure that out first, hah!)

Since it is new to me, this was the easiest way for me to figure out how to do it, if there is a better way, someone jump in.

 

Thanks,

John

In reply to John Banner

Re: Bootstrap Themes

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

Following on from my last comment,John, you may be interested how I designed my first Moodle bootstrap theme? 

https://github.com/lazydaisy/tiny-bootstrap-project

it uses a

span3 | span6 | span3

layout which I was told, was the wrong way to code it...but it works none the less and is less complicated too!

cheers 

Mary

Average of ratings: Useful (1)
In reply to Mary Evans

Re: Bootstrap Themes

by John Banner -

Thanks! I just installed it on 2.6 and each block and course content is in its own region. I wish I would have found this before racking my brain on "Clean". I dont see why it would be the wrong way to do it, it seems to work just fine, even with the way I modified "Clean" and it does seem easier to adjust widths.

 

Thanks Again!

In reply to John Banner

Re: Bootstrap Themes

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

Great! Please let me know if you need help changing it?

Cheers

Mary