Changing the layout of moodleforms

Changing the layout of moodleforms

by Mike Worth -
Number of replies: 11
I've got a moodleform that displays as one long column; as the fields are narrow this wastes a lot of screen space and requires scrolling where it would be nice not to.

Is there a way to align them differently?

Thanks,
Mike
Average of ratings: -
In reply to Mike Worth

Re: Changing the layout of moodleforms

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
You can use CSS. moodle forms give you plendy of divs with specific classes to apply styling to.

Or you can use groups to put multiple settinsg on one line.
In reply to Tim Hunt

Re: Changing the layout of moodleforms

by Mike Worth -
I've had a look, it seems that groups are nearly what I want (the inputs are closely related anyway), the only problem is I loose the labels. I'd be happy with a single label for the group but can;t see where to define it.

Thanks,
Mike
In reply to Mike Worth

Re: Changing the layout of moodleforms

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Have a look for some other forms that use groups (use a global search tool on the code). I am sure you will find some forms that make creating use of groups.
In reply to Tim Hunt

Re: Changing the layout of moodleforms

by Mike Worth -
I can do some of it with groups (and have found the label parameter), but it's looking like I'm going to need css for other bits. I've only very briefly played with css in the past (My work tends to work, but I don't really care what it looks like), and cannot figure it out. The fitems are held within another div which seems to be stopping me from changing their layout at all.

Is there a property I can change so that some of them (here's another issue, I can set the class of the select but can't find a way to set a second class for certian fitems) to display horizontally (all next to each other)

Thanks,
Mike
In reply to Mike Worth

Re: Changing the layout of moodleforms

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Firefox web developers toolbar and firebug are useful tools for experimenting with CSS. And there are plenty of tutorials on the web.

But the kind of tricks you need to get Moodle forms to layout the way you want may not be the best place to start learning.

However, setting

display: inline;

on some of the divs might be a good way to start. (Similar to removing the div altogether, in some senses.
In reply to Tim Hunt

Re: Changing the layout of moodleforms

by Mike Worth -
I've had a play and seem to be getting somewhere, but am up against the problem of getting class identifiers into the divs; I want to do different things with different form elements but am currently stuck with only the general classes.

Thanks,
Mike
In reply to Mike Worth

Re: Changing the layout of moodleforms

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Don't some of the elements have ids?

Ah, I see, only the sections of the form have ids like <fieldset id="reviewoptionshdr" class="clearfix">. That's a pain. (Although it was sufficient the one time I needed to do this sort of thing.)

It might be nice if the outer <div class="fitem"> had an id like id="{fieldname}-wrapper" applied to it. What do people think about that?
Average of ratings: Useful (1)
In reply to Tim Hunt

Re: Changing the layout of moodleforms

by Frank Ralf -

Hi, Tim,

I would really welcome that and propose it as a general design concept which would make changing the layout of your Moodle site much easier, just using CSS without the need of modifying HTML or even PHP code.

I come from a Drupal background, and Drupal makes extensive use of DIV ids and classes. Here's an example from a block in the right sidebar of our school's website (http://www.grundschule-heidhorst.de):

<div id="sidebar-right-inner">
<div id="block-block-5" class="block block-block region-odd even region-count-1 count-4">
<div class="block-inner"> ...

Drupal's Zen theme does a great job of providing a very flexible and purely CSS based theme (http://drupal.org/project/zen).

I think implementing this would be one small step for a developer, but one giant leap for Moodle. wink

Kind regards, Frank

In reply to Tim Hunt

Re: Changing the layout of moodleforms

by Urs Hunkler -
Picture of Core developers
Tim and Frank,

@It might be nice if the outer
had an id like id="{fieldname}-wrapper" applied to it.

Great proposal. Can you manage to get this enhancement into 1.9.4?