Styling lesson headings

Styling lesson headings

על ידי James Pengelly בתאריך
מספר תגובות: 9
Hi Using Moodle 2.1, the main headings in the lesson pages (lesson title and page / topic title - the bits that appear in the navigation menu) are both styled as h2 class="main". Is there a way to apply different formatting to them or does anyone know where this content gets built so that (say) the topic title could be changed to h3 class="main"?
ממוצע דרוגים: -
בתגובה ל: James Pengelly

Re: Styling lesson headings

על ידי Chris Collman בתאריך
תמונה של Documentation writers

Hi James,

 I assume you are talking about the"left menu" that can be turned on in the Lesson settings.   You know that every Theme will/can display this block different via its theme/mytheme/style/***.css files or  its parents found in theme/mytheme/config.php.   

I am not the code person and know just enough about CSS to be VERY dangerious.  (ie, it takes me a long time to do anything custom). 

I did look at mod/lesson/ renderer.php which is new in 2.0 as a standard file.   There is a bit there that says "Returns HTML to display a page to the user".    You are welcome to back track the php code from there חיוך

I did note in the page source code  that the body had an id <body id="page-mod-lesson-view" ....>, so my CSS guess is you could write a subclass in your theme for just your lesson pages associated with that id.

It would seem to me by creating a CSS subclass in a custom theme (see Themes FAQ for some clues), you 1) would only impact the lesson module display,  and 2) you will not have to mess with the /mod/lesson code. Custom themes survive Moodle upgrades than having a list of display codes you placed in the core moodle code, IMO.

Hope this helps and someone who knows more about CSS and php can enlighten us further. 

בתגובה ל: Chris Collman

Re: Styling lesson headings

על ידי James Pengelly בתאריך

Thanks Chris

I've attached a screenshot to try to make it a bit clearer. Both the elements are within page-view-lesson and within that they're both in the same div so unfortunately that doesn't help.

I want the lesson title (red circle) to be formatted differently to the page title (blue circle) but as they're both h2 class=main there doesn't seem an obvious way to do this.

I can't find a pagetype for "content" and searching the files for h2 or class=main hasn't thrown anything up.

If anyone can advise where this page content gets built it'd be much appreciated.

בתגובה ל: James Pengelly

Re: Styling lesson headings

על ידי Tim Hunt בתאריך
תמונה של Core developers תמונה של Documentation writers תמונה של Particularly helpful Moodlers תמונה של Peer reviewers תמונה של Plugin developers

These headings will be output by calls to $OUTPUT->heading() (or possibly $renderer->heading()) in the lesson code. I guess one needs to be changed to h3, or we need to add some more class names to one.

בתגובה ל: James Pengelly

Re: Styling lesson headings

על ידי Joseph Rézeau בתאריך
תמונה של Core developers תמונה של Particularly helpful Moodlers תמונה של Plugin developers תמונה של Testers תמונה של Translators

Hi James,

In the Lesson activity, page titles are only displayed for pages of the "content page" type. Page titles of the "question" pages (multiple choice, etc.) are not displayed.

Anyway, a quick and dirty solution is as follows, if you are willing to hack your moodle core files.

Edit mod/lesson/pagetypes/branchtable.php file, line 113 to replace

$output .= $renderer->heading(format_string($this->properties->title));

with

$output .= '<h3>'.format_string($this->properties->title).'</h3>';

Joseph

בתגובה ל: Joseph Rézeau

Re: Styling lesson headings

על ידי Tim Hunt בתאריך
תמונה של Core developers תמונה של Documentation writers תמונה של Particularly helpful Moodlers תמונה של Peer reviewers תמונה של Plugin developers

Even better to replace it with $output .= $renderer->heading(format_string($this->properties->title), 3);

בתגובה ל: Joseph Rézeau

Re: Styling lesson headings

על ידי Sebastien M. בתאריך
Hi Joseph,

Is there a way to display page titles for question pages? IT would be great if it could be inserted into the empty legend tag that is already rendered.

Regards,

Seb

(FYI: using Moodle branch 2.3.2)
בתגובה ל: James Pengelly

Re: Styling lesson headings

על ידי Chris Collman בתאריך
תמונה של Documentation writers

Glad you did the screen shot.   Tim and Joseph know the code.  

No place to slip in some CSS code tweaks, unless you want the entire site changed. Chris