Dock confusion

Dock confusion

by Howard Miller -
Number of replies: 13
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
I've done a few Moodle 2 themes now (so I have a vague idea what I'm doing) and I've never bothered with the docking feature at all. I've been creating themes by extending the Canvas theme which has it turned off - I've got no particular reason for using the Canvas theme other than it implies that's what it's for.

So, a client requested that the docking work in their theme. Panic ensues, but I switch on the option in the theme config. It sort of works but docking one block in the side-bar makes all the blocks vanish.

Before I spend ages tracking this down, is there a simple answer where I might have gone wrong. Block styling was exclusively font/colour changes. Nothing fancy in this theme at all.

Cheers smile
Average of ratings: -
In reply to Howard Miller

Re: Dock confusion

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

Yes...you need to add some php code into the layout files...general.php and frontpage.php which I think are present in base theme's layout files but not canvas, from memory.

$showsidepre = ($hassidepre && !$PAGE->blocks->region_completely_docked('side-pre', $OUTPUT));
$showsidepost = ($hassidepost && !$PAGE->blocks->region_completely_docked('side-post', $OUTPUT));

and

$bodyclasses = array();
if ($showsidepre && !$showsidepost) {
    $bodyclasses[] = 'side-pre-only';
} else if ($showsidepost && !$showsidepre) {
    $bodyclasses[] = 'side-post-only';
} else if (!$showsidepost && !$showsidepre) {
    $bodyclasses[] = 'content-only';
}

Checkout Standard theme as this uses no layouts of its own, but uses base theme's layouts.  If you want a copy of a new theme based on standard which I have just made, and which has a nice looking 'dock' send me your email in a PM....and I'll email you a copy.

Cheers

Mary

In reply to Mary Evans

Re: Dock confusion

by John St -

You'll also (I think) need to add the block-region class to the region # like: 

<div id="region-pre" class="block-region">

That should keep the other blocks from disappearing as well. 

In reply to John St

Re: Dock confusion

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Thanks for the help but it doesn't make any difference at all.

I swapped canvas's general layout for the one from the base theme and docking works perfectly. However, all my other changes are broken.

The moral is, don't use the canvas theme as a base if you want docking to work. Sigh... looks like I need to start again using the base theme.
In reply to Howard Miller

Re: Dock confusion

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

Howard,

Using general.php from base is OK that's what I do. But if you want canvase to style some of your new theme as you had Canvas as a parent, then make sure you have both Canvas & Base as your parent themes this is what you should have done. So DO NOT take Canvas OFF as this will style your theme as you had it as it was relying on Canvas in the first place.

So to recap.

Parent themes should be as described in my other post of yesterday.

parent = array('canvas', 'base') and you should be good to go.

Sorry can't remember the correct code! I only logged in because I needed to see if BT tinternet was working as am setting up BT Vision but could not bear to think you were in dire straights over this theme business! LOL

Cheers

Mary

In reply to Mary Evans

Re: Dock confusion

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Hi Mary,

Yes - I did have canvas and base as parent themes. However, I copied the general.php layout from canvas into my theme's layout as I needed to make some changes. The two layouts are sufficiently different that it stuffs up a lot that I did.

I just backed the wrong horse for a layout file, unfortunately. I'd made some changes in the header area of the layout so I need to move those into the other layout (but they are surprisingly different). I'm still a bit miffed that a better way wasn't thought to deal with headers. It's the only bit of the layout I ever want to change. Could be just me of course smile

BT Vision? Show off! I live up a hill in some obscure corner of Scotland - I'm lucky to get internet at all smile
In reply to Howard Miller

Re: Dock confusion

by Richard Oelmann -
Picture of Core developers Picture of Plugin developers Picture of Testers

lol Howard - sounds like my situation too smile Live on the outskirts of a town in S.Wales that's supposed to have good broadband, but half way up a mountain and right at the outer limits of the phoneline which means I get about .5 of my 'upto 20Mb'!!!

In terms of the layout, I generally use standard (and base) as my main parent as that uses the dock, and build things off that. But I've also built themes that start from scratch and do their own thing with headers - and a couple that used a separate php include to call a different header file entirely (mostly these were for my own learning and trying things out rather than for practical use though), including one I'm working on at the minute in work because the current 1.9 moodle is integrated with lots of other pieces of the intranet and currently has a separate header html file. So it can be done, you don't have to use the complete base layout file instead of the complete canvas one - You could think about taking the header part of the layout of the one file which you've already adapted to replace the header part of the one that has the dock functions in on the one you want to use. It might mean fewer changes to the css you've developed?

Just a thought smile

Richard

In reply to Richard Oelmann

Re: Dock confusion

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Ye-es, unfortunately (as I'm sure you know) the base layouts have their problems. Nothing major but stuff like the zero height "page" div. The nature of layouts is that they have become horribly inconsistent (e.g. a main-content-wrapper was added in canvas but never put back into base). So, unfortunately, what I think we *don't* have is a rock solid, do-everything theme from which to spring new themes.

Base is a bit rough and canvas (which advertises itself as such a thing) is broken for docking (at least). It's a bit of a shame sad
In reply to Howard Miller

Re: Dock confusion

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

Hi Howard,

Dietmar and I are working on the pagelayouts for all the themes, and finding more problems as we mine the code. The idea is to try and simplyify report layout so that all themes use base theme.

However, base theme has got a zero page height, which can be fixed by adding <div class="clearfix"></div> just before the last </div> in both frontpage.php and general.php in your theme.

I'll send you a link to download the theme I made recently it's very basic. It uses standard and base as parents.

As for Canvas, well that theme needs updating as it should have the dock adding just in case people want to clone it to use as a base for a custom theme.

Cheers

Mary

In reply to Howard Miller

Re: Dock confusion

by John St -

I use canvas, and docking, every day and have never had an issue with docking. I'm not sure where the issue might be for you, but I don't see it. 

-edit-

Attached is a simple canvas based theme with docking enabled. All you needed to do was add the block-region class as I noted above.

In reply to John St

Re: Dock confusion

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

Personally I think Canvas needs updating as I mentioned to Howard. The dock elements should be in the layout files. They don;t need to be activated in Canvas but would have been better had they were.

I think that when Patrick built this theme in the first place he was just learning how it worked. Now we know more there are elements like the dock which were in the early stages of Moodle 2.0 themes, not available and to tell you the truth, few people knew how thay work.

There are still lots of errors in these themes and the more you fix the more you uncover. In short some are a bit of a mine field.

Cheers

Mary

In reply to Mary Evans

Re: Dock confusion

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
It's good to hear that work continues to done on all of this.

I remain a bit unconvinced that layout files where the best way to do this. It's certainly very flexible if you intend to invest lots of time in sparkly new themes but is way too complicated for the casual theme dabbler (i.e. me).

I realise that the intention is that you can inherit from existing themes but it means making some sensible choices and that can be a bit hit and miss at the moment.
In reply to Howard Miller

Re: Dock confusion

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

You sound like a Scotsman when you talk like that!

and I am tempted to reply...

Ayeee...!

smile