Moodle 2.0 headers and footers

Moodle 2.0 headers and footers

by Howard Miller -
Number of replies: 27
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Just so I've got it straight.... each layout file in a theme redefines the headers and footers, yes?

So (scenario coming up) if I which to create new theme B which has a parent theme A and my client says "make the header look like whatever on every page", the only way to do that is copy *every* layout from the parent theme into my new theme and then modify the header code in *every* one of those files?

Seems so crazy as to be unlikely, surely? Changing the header layout is the number one request for a custom theme.
Average of ratings: -
In reply to Howard Miller

Re: Moodle 2.0 headers and footers

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

There where always 2 headers types in the header.html.  header-home and header. In Moodle 2 we have general.php and frontpage.php similar idea, but two seperate pagelayouts giving more flexibility for theme designers.

Development:Themes 2.0 creating your first theme

You should find this a good starting point, Howard, to learn more about Moodle 2.0 themes.

Cheers

Mary

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

Re: Moodle 2.0 headers and footers

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
In the nicest possible way you are dodging my issue slightly smile That would be true if those where the only page layouts. Some themes have more layouts than that and, if I'm not wrong, if you don't like the header then you need to change (or more correctly override) *all* the layouts.

Creating your first theme gets around this by having one layout for everything which is interesting in itself but might not be what you need.

In 1.9 you could just force the 'if' statement the checked for the homepage to true and have all headers the same. There's no equivalent in Moodle 2.0. I'm not sure if an include/require is possible for layouts which would easily solve the problem.
In reply to Howard Miller

Re: Moodle 2.0 headers and footers

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

Some themes do have more layouts than others, I grant you, but if you look in those themes' config.php files you will see that only four layouts would be used (on average), of which only two will need headers, these being frontpage.php and general.php. Also not every php file in the layout folder is a layout. Some php files are used as includes within a layout page.

Actually, Howard, I don't see what you are really getting at, I think you are just being pedantic. How many headers would one want in a Moodle set up anyway? Do people what a different header on every page?

If you are talking styles then you can have as many styles of headers as you need just using CSS and one layout. Take a look a the CSS Zen Garden and you will see what I mean.

Mary, Mary quite contrary!

In reply to Mary Evans

Re: Moodle 2.0 headers and footers

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
I'm very good at being pedantic big grin However, it's just me trying to get it straight in my head - that's how you get to the bottom of a (possible) problem.

My concern is/was that I spend a lot of time producing themes where all the page headings are required to be the *same*. That used to be easy because there was only one header file and commenting out at couple of lines achieved exactly that. Now there are at least two and that's more work, maintenance and possible errors. Granted I could produce a theme with one layout that does everything but that's probably more work too.

This hasn't anything to do with CSS. This is for (boring) commercial clients who actually want everything to look identical so the layout code needs to be identical for each layout type. Equally well, I want to base them on a core theme because I get to do loads of these.

To be completely fair, I actually need to go and try to do some things rather than staring at code. The fact that you can safely include one layout file from another is reassuring too. If I can rip out the header code and include it in all layouts that need a header then that's my answer. Thanks and sorry if I asked the wrong question in the first place smile
In reply to Howard Miller

Re: Moodle 2.0 headers and footers

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

Howard, I don't really understand your worries about this as, from what you are saying about the types of Moodle 1.9 themes you create for your commercial clients, this to me sounds like a doddle in Moodle 2.0. What could be easier than a corporate look?

I don't think you asked the wrong question, Howard, I just think your first take on Moodle 2.0 theme layouts was way off course that's all, at least it sounded so to me. But then I've been playing about with Moodle 2. themes most of this year and seen the changes made to the layouts, which I know insideout. I started a discussion about the pagelayout earlier this year, which ended up thrashing out the wheat from the chaff, in otherwords getting the teminology of the layout standardized.  Urs was very much involved in this and thanks to him we are using his ideas for the terminology of the actual layout.

There has been so much going on in this forum over the last twelve months, that it is a pity not may people have taken that much notice of, and now everyone is going crazy because Moodle 1.9 themes are not compatible with Moodle 2.

Had it not been for the 'loud voices' who knows where Moodle Themes would be now.

Mary

In reply to Howard Miller

Re: Moodle 2.0 headers and footers

by Urs Hunkler -
Picture of Core developers

Howard, it's scary how derogatory you talk here about "(boring) commercial clients who actually want everything to look identical" as a Moodle Partner. I hope they don't read your posting.

I answer to your posting because I think it is still symptomatic for many representing Moodle or Moodle development to neglect or not understand the role of corporate design or good user interfaces. Good and consistent user interfaces are a base for good usability. And the usability of a learning environment is a key factor for online learning. You really might be well-advised to accept that facts and act accordingly.

In reply to Urs Hunkler

Re: Moodle 2.0 headers and footers

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
That's not what I meant.... and I think you know it wasn't. I am talking about users who only require a minor change to make the headers consistent across pages. This is (for me anyway) a very common request.

When I want to be educated about good theme design I'll make sure to come and ask for the facts and act accordingly. But right now I just wanted to know the best way to change a couple of things in the header (in more than one place).
In reply to Howard Miller

Re: Moodle 2.0 headers and footers

by Mauno Korpelainen -

The main advantage of several layout files is that you can change layout and use different headers, content and footers for different cases.

I have used simple php tags like

require ("extras.php");

for such similar parts that need to be used in several layout files. One of my test themes is using 3 basic layout files and each of these separates the code for mobiles + there are some "header extras" (math javascripts), user preference code etc.

In reply to Mauno Korpelainen

Re: Moodle 2.0 headers and footers

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Yep - that sounds like the answer.

Producing themes for commercial clients turns into a theme "sweat shop" and any way to increase productivity is welcome.

I started off a bit horrified because Moodle 2.0 themes looked like a lot more work to adapt. They are, I think. But it's not as bad as I thought.

Thanks Mauno.
In reply to Howard Miller

Re: Moodle 2.0 headers and footers

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Howard, I completely agree with you. It took major brow-beating by people in this forum (mainly Urs) before I implemented this, and I was never convinced that it was good software design (with all the duplicated code it impleies). However, I was convinced that it was what 'theme designers' wanted, and the most vocal of them would not shut up until we did it.

Judging by most of the comments here as people get to grips with Moodle 2.0 themes, this is what people want, so we (mainly Sam and Petr building on my initial implementation) got it right.

There are two main saving graces to get round the "you need to duplicate code between all the layout files" problem

  1. These are PHP files, so you can refactor the duplicated code into a function, so that when you make a new theme, you only have to change the one function, not all the layouts.
  2. The way Moodle 2.0 lets you derive new themes by starting with a parent theme and then just tweaking bits of it in your new sub-theme should be very helpful for theme sweatshops. A good example of that is the way that a lot of the new themes that Patrick Malley did for Moodle 2.0 derive from the canvas theme.
In reply to Tim Hunt

Re: Moodle 2.0 headers and footers

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

Well Tim, it's a good thing that there are people who do take an interest in the designability of Moodle 2.0, and from what I have seen in recent posts here, Urs is still very much a spokesman for those of us who like to design themes, and get systems inplace so as to make the job easier.

Mary

In reply to Mary Evans

Re: Moodle 2.0 headers and footers

by Urs Hunkler -
Picture of Core developers

Thank you very much for your posting showing me that I am not the only one seeing some offensive tenor in Tim's contribution. And it's good to know in such situations to know that there are people thinking similarly.

In reply to Tim Hunt

Re: Moodle 2.0 headers and footers

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
big grin

Thanks Tim. I think I was having an "aargh, duplicated code" moment. As you say, it's easily sorted if required.
In reply to Tim Hunt

Re: Moodle 2.0 headers and footers

by Urs Hunkler -
Picture of Core developers

Tim, I don't understand what you intend with such offensive sentences like "It took major brow-beating by people in this forum (mainly Urs) ...". Do you feel a need to restart our war? Or do you need to make other people down to be able to shine in your developer glory?

The right answer for Howard may have been RTFM. But showing possible solutions is much more productive.

You have done marvelous work and Petr and Sam could build on the base you created. There is no need to complain, to accuse or offend people. The Moodle 2.0 theme system is a good base to work with and to continue building on it to make it even better.

You may go and blame your developer colleagues for crappy work like the course/category... pages. I created the tracker issue MDL-25649 explaining the inconsistencies in some related pages.

These pages are a nightmare for people working with the Moodle user interface. We need to correct each developer fault in CSS individually for each page. And that only because Moodle features are still more important than a consistent user interface and code quality. These topics don't show up in any roadmap.

In reply to Urs Hunkler

Re: Moodle 2.0 headers and footers

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Urs, it is very clear that you don't understand anything about me. (And yet, you still launch a personal attack on me in a public forum. You might like to reflect on that.) I don't understand you either.

To help you just understand, can I just say that I spent 8 years at university studying mathematics. A mathematician is the last person in the world to use "Argument from authority". (I was trying to think of an analogy, since I guess that most people here are not mathematicians. the best I could come up with is "You may as well accuse a priest of using the scientific method. I'm not sure that really captures it. Anyway.)

When I come to these forums, I expect a debate on the technical issues we all have to resolve to help Moodle move forwards. I want that debate the proceed based on logic, evidence, and so on. Personal opinions are irrelevant. My experience in other forums is that when you have debates like that, and the result is something new for Moodle that is better than any one person could have thought of on their own. It saddens my that attempts to debate like that in this forum always devolve into personal attacks.

In reply to Tim Hunt

Re: Moodle 2.0 headers and footers

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

I too have a degree in Mathematics BSc(Hons) 1996 - Oh how jolly!

 

In reply to Mary Evans

Re: Moodle 2.0 headers and footers

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Mathematics & Computer Science Joint BSc 1985 - spot the old guy!
In reply to Tim Hunt

Re: Moodle 2.0 headers and footers

by Mauno Korpelainen -

I am happy to notice that a huge majority of people here are mathematicians wink

I finished my Master of Science in Mathematics in 1991 smile

In reply to Mauno Korpelainen

Re: Moodle 2.0 headers and footers

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

Sorry to sound a jarring note in this otherwise instructive thread.

Joseph (a non-mathematician who has always hated maths at school wink)

In reply to Mauno Korpelainen

Re: Moodle 2.0 headers and footers

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

So, does that mean as an Accounts/Finance grad with a teaching PGCE I'm out of my depth among all you Mathematicians and scientists!!! :D

(Well, I may be, but that's not to do with my degree! lol!)

 

Richard

In reply to Richard Oelmann

Re: Moodle 2.0 headers and footers

by Marc Grober -

Hey,  someone throw some gas on the fire and let's see if we can get someone banned from the forums!

In reply to Richard Oelmann

Re: Moodle 2.0 headers and footers

by Mauno Korpelainen -

Not at all big grin

“Die Mathematiker sind eine Art Franzosen; redet man mit ihnen, so übersetzen sie es in ihre Sprache, und dann ist es alsobald ganz etwas anderes.” (Mathematicians are [like] a sort of Frenchmen; if you talk to them, they translate it into their own language, and then it is immediately something quite different.)
— Johann Wolfgang von Goethe

“It is easier to square the circle than to get round a mathematician.” — Augustus De Morgan (1806-1871)

“Mathematics may be defined as the subject in which we never know what we are talking about, nor whether what we are saying is true.” — Bertrand Russell

“The important thing in science is not so much to obtain new facts as to discover new ways of thinking about them.”  — William Lawrence Bragg

“Anybody can become angry - that is easy, but to be angry with the right person and to the right degree and at the right time and for the right purpose, and in the right way - that is not within everybody's power and is not easy.”
— Aristotle

 

Average of ratings: Useful (4)
In reply to Mauno Korpelainen

Re: Moodle 2.0 headers and footers

by Urs Hunkler -
Picture of Core developers

Kudos Mauno, you are a marvelous moderator.

Your cite collection made me smile.

In reply to Urs Hunkler

Re: Moodle 2.0 headers and footers

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

Can I just clarify a bit here ... I know Tim pretty well, and when I read this post I read it as being self-deprecating, saying that developers needed a brow-beating sometimes.   Which is true.  We need your feedback, and we need people to fight for things. smile

Let's get those niggly last areas sorted out in the next few releases.

Love you all!

Average of ratings: Useful (2)
In reply to Howard Miller

Re: Moodle 2.0 headers and footers

by Urs Hunkler -
Picture of Core developers

My proposal is to use the Moodle 2.0 theme system and extend the "$THEME->layouts" settings in the theme config.php and create your renderers for your headers and footers.

You may add an item 'includes' = array( 'header' => array( 'theme' => themenametotakeheaderfrom, 'include' => 'header_home.inc.php), 'footer' => array( 'theme' => themenametotakeheaderfrom, 'include' => 'footer_with_special_info.inc.php)) to "$THEME->layouts" and read the config data from your renderer. This way you are flexible to save your includes in any theme and reuse them from any theme or create individual and theme specific ones.

For Moodle 2.0 you might end with the config.php, a styles.css and one or two include files for a client specific theme. All other layouts, icons, files etc. you may take from parent themes. Compared to Moodle 1.9 I see this as a huge advantage.

In reply to Howard Miller

Re: Moodle 2.0 headers and footers

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Well, this is interesting. Thanks for the "burn the witch" responses. Possibly I didn't explain myself very well but perhaps everybody stopped reading when I questioned their precious theme design. And, in fact, I only asked for clarification to make sure I understood anyway.

Let me try one last time and then I shall not trouble you again...

I am talking about large volume relatively low cost commercial hosting. There is something built into this for theme customisation. I'm not talking about thoughtful, lengthy theme customisation here. I am talking about making a few minor changes to a strandard theme which often enough to keep a small business trying out Moodle happy who have not budgeted for a full theme design.

I am not asking about the pros and cons of good theme design for corporate user. I might care about that a lot some other day but right now I have a job to get done and I wanted to know how headers where handled. That's it, nothing else, not interested (today)!!

The fact is that the new setup makes this slightly more complicated. Not so much that I want to kick up a big fuss or call your baby ugly. Thank you, by the way, for those who pointed out the workarounds.

Anyway, have fun with your lovely themes.