Questions locking docks and icons for blocks/headers

Questions locking docks and icons for blocks/headers

by J Catchens -
Number of replies: 17

Two Questions:

1. Is it possible to force certain blocks to dock for a specific theme?  For example, I want the default look of my theme to have blocks like navigation permanently docked on the side of my theme.  Is there some CSS/Moodle option to lock this?

2. Is there a way to add icons for side blocks and headers?  Consider the front page, I would like "Site News" to have one icon and "Available Courses" to have another.  I though about using the background image trick, but it seemed there was no CSS distinction between the differing headers.  The same question for side blocks, as I want my icon to overlap both the header and content of the block.

Also, is there a way to override the images for hide and move on the side blocks?

Thanks for any assistance.

Average of ratings: -
In reply to J Catchens

Re: Questions locking docks and icons for blocks/headers

by Sam Hemelryk -
Hi J,

There is presently no easy way to force blocks to dock by default.
However I wrote the dock I did make it possible to mark to be docked immediately when the page loads, this is how the blocks a user has docked previously are docked on every page load. All you need to do is add the css class dock_on_load to the block, which unfortunately is easier said than done.
Probably the best way to do it presently would be to override the core renderer, and in particular core_renderer::block(). If this is an option you would like to explore check out the Development:Themes 2.0 overriding a renderer.
If you get stuck you can always ask here for help.

Alternatively you could create a feature request in our tracker and try get votes for it, this may or may not see the feature created depending on how people feel about it.

Regarding the side blocks and headers, the side blocks you should be able to style as you want, each block has a CSS class that describes the block, e.g. .block.block_navigation.
The main content headers unfortunately don't have any nice descriptive CSS classes, although I have created MDL-25630 to see about wrapping the content in divs with descriptive classes to make styling possible.

Cheers
Sam

Average of ratings: Useful (2)
In reply to Sam Hemelryk

Re: Questions locking docks and icons for blocks/headers

by Beto Castillo Llaque -

im sorry , how and where i can add the class dock_on_load to specific theme?

In reply to J Catchens

Re: Questions locking docks and icons for blocks/headers

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

Check out liip theme in the Moodle Themes database HERE

DEMO site HERE

This is the nearest thing I could think of which may or may not be what you are searching for!

Cheers

Mary

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

Re: Questions locking docks and icons for blocks/headers

by Mathew Gaudieri -

Hi guys.

Im wanting to do the same thing. Basically I want the navagation and settings on the dock for every user. Im having abit of trouble enforcing this. Can anyone help me with this?

 

Cheers.

In reply to Mathew Gaudieri

Re: Questions locking docks and icons for blocks/headers

by Ruth Cheesley -

Same thing here - need the nav & settings to be docked automatically.  I'd have thought it would be a sensible thought process to have underneath the 'allow users to dock this module' the option to select 'always dock this module' ?

Ruth

In reply to Ruth Cheesley

Re: Questions locking docks and icons for blocks/headers

by John St -

If you add the class .dock_on_load (as Sam mentioned)  to a block, it will do just that everytime a page loads... 

So, you could use a renderer (like the hackish one attached) to add the class to specific classed blocks. The one attached does it to the nav block. 

The downside is that the user is forced to have the block docked on every new page load, even if they don't want it there anymore... Not sure if this helps, just though it was a neat addition to the discussion.  

Average of ratings: Useful (2)
In reply to John St

Re: Questions locking docks and icons for blocks/headers

by Nicolas Martignoni -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators

Thanks for this file John.

Adding the class .dock_on_load does the trick for most of the blocks. But unfortunately, it doesn't seem to work for HTML blocks. Any idea?

PS. One could also add the class with JQuery or YUI, e.g.

function init() {
    YUI().use('node', 'io', function(Y){
      // Dock all blocks by default
      Y.all('.block').addClass('dock_on_load');
  });
}
YUI().use('*', function(Y) {
  Y.on("domready", init, Y);
});



Average of ratings: Useful (1)
In reply to Nicolas Martignoni

Re: Questions locking docks and icons for blocks/headers

by Nicolas Martignoni -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators

Ok, I found why it didn't work, and the answer is in one word: timing.

Adding the class via YUI is a bad idea, as the code check for the dock_on_load class occurs approximately at the same time! Thus, the first block had not yet the dock_on_load added at the time of the check and was not docked.

Conclusion: use the renderers.php trick to add the class.

In attachment, find my version of renderers.php, that add dock_on_load class to every block displayed.

Cheers!

In reply to Nicolas Martignoni

Re: Questions locking docks and icons for blocks/headers

by Volker Trinkner -

Hi Nicolas,

your solution works pretty well - after having edited "class theme_<this must be edited with the name of your theme>_core_renderer extends core_renderer ..". Thank you.

There is still one issue left (and this may be also a timing problem):

When calling the page the first time (I use the formal_white theme) , all the blocks are moved to the dock but the space will NOT be resized (there is no block left). Refreshing the page it will be resized. Any idea?

Regards, Volker

In reply to Nicolas Martignoni

Re: Questions locking docks and icons for blocks/headers

by ana paula caruso -

I used this renderer to lock the blocks, and added some instances so it would leave some blocks not docked, but it's only working in the course mainpage, once I go further the blocks are not docked at all...

there's something that I'm missing in the process? 

In reply to ana paula caruso

Re: Questions locking docks and icons for blocks/headers

by llywelyn morgan -

Both Sam and John's code work for me, however:

Sam: I've tried editing the code to apply to multiple blocks but can't seem to get it right.  What code do I add?

John:  Is it possible to apply this code to selected blocks rather than all of them?

Fingers crossed there'll be a core update with this feature.

Thanks for your time and effort.

Llywelyn

In reply to llywelyn morgan

Re: Questions locking docks and icons for blocks/headers

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

You will only get this feature in Moodle CORE if someone creates a Moodle Tracker and gets people to vote for it.  Sam sugessted this last year but I don't recall seeing a tracker set up for it. Perhaps if you did this your wish may come true!

Cheers

Mary

In reply to llywelyn morgan

Re: Questions locking docks and icons for blocks/headers

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

Hi Llywelyn,

I have just searched Moodle Tracker and found MDL-26816 which, if it were implemented, would automatically dock blocks on login.

I need to make people aware of this and get them to vote.

Cheers

Mary

In reply to Mary Evans

Re: Questions locking docks and icons for blocks/headers

by llywelyn morgan -

I've voted for that already.  Let's hope somebody has enough spare time to implement it.  smile

In reply to John St

Re: Questions locking docks and icons for blocks/headers

by Manuel García -

This solution works great for me. I was looking for a way to force de settings and navigation blocks to the dock.

Just put the file renderer.php (you will have to hack a little to reach your requeriments) in your theme directory and add:

$THEME->rendererfactory = 'theme_overridden_renderer_factory';

to your config.php file.

Thanks and best regards.

In reply to John St

Re: Questions locking docks and icons for blocks/headers

by Marc Hermon -

Thanks, I added the code to my renderers file in my theme and now the navigation block docks on every page load. Now, how do I choose other blocks to dock automatically also. Primarily I want to also dock the Settings block on each page load. I'm not smart enough for it to be real obvious to me.