Getting rid of tags

Getting rid of tags

by David Scotson -
Number of replies: 7
I'm just trying to restyle the login page and the fact that the message

"Login here using your username and password
(Cookies must be enabled in your browser)"

is broken in two by the use of two br tags rather than being marked up as two paragraphs is kind of annoying me since it renders them basically unstylable.

Is this something that I could fix (along with the various other examples) and get accepted back into Moodle for say 2.5 or is there some reason why those br tags are used in translatable content? I looked at another bit of translatable content which has pre tags in it, but by the time it gets to the screen extra paragraph tags have appeared around the content before and after the pre tags. I tried to follow the (very complicated!) process of strings getting outputted by get_string but still couldn't work out where those extra tags were coming from so I'm a bit hesitant to just dive in and start changing the text to something "better" if it's going to screw things up.

Does anyone have any ideas?
Average of ratings: -
In reply to David Scotson

Re: Getting rid of tags

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

Hi David,

Which file/s are you trying to change? 

I don't see any problem in suggesting it gets changed. In fact I dare say Moodle HQ would be pleased if it looks better, and easier to style.

Perhaps we could tag this improvement on to the list of changes Amy has set out that I will begin working on this weekend? See MDL-37264

I must admit it has puzzled me when I see <br> and sometimes <br /> used in coding which I think is pretty bad as it would be better, as you say, to use <p> tag but then YUI stylesas p { bottom-margin: 1em;} so I guess <br> is a safer option.

Cheers

Mary

In reply to Mary Evans

Re: Getting rid of tags

by Amy Groshek -
Do it! :D

I also totally don't get why the login button is placed wrapped in a div with the password input. IMHO it should be centered below both fields, and the markup doesn't really facilitate that.
In reply to Mary Evans

Re: Getting rid of tags

by David Scotson -
The first file that inspired this question were:

enrol/flatfile/lang/en/enrol_flatfile.php

Which has example CSV files in pre tags but the text isn't marked up, but if you visit the page that outputs that string:

admin/settings.php?section=enrolsettingsflatfile

you see paragraph tags have appeared.

For the front login page the text I mentioned I assumed it was coming from a lang file (since there are a bunch of br tags in lang files) but actually the formatting (including the br) is in this file:

login/index_form.html

I'm going to rewrite it in Bootstrap style but would be happy to contribute if people wanted to give it a tidy up for standard 2.5

In reply to David Scotson

Re: Getting rid of tags

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

Hi David,

This happens in a theme's Custom settings page too.  If you look at any theme custom settings page you see <p></p> wrapped round these language $strings...

    // Logo file setting
    $name = 'theme_afterburner/logo';
    $title = get_string('logo','theme_afterburner');
    $description = get_string('logodesc', 'theme_afterburner');
    $default = '';
    $setting = new admin_setting_configtext($name, $title, $description, $default, PARAM_URL);
    $settings->add($setting)

...so I guess the output for these $strings are predefined somewhere in Moodle.

EDIT:

Just got word back from Tim Hunt who says the following...

(5:55:27 PM) Mary Evans: Can anyone tell me where I might find the source file that determines how a theme's custom setting page (theme/themename/settings.php) is configured/output? What I want to know is how is formatting added? Where is it coming from. Things like <p></p> tags appear around sentences as though by magic.

Here is Tim's Reply:
(5:57:28 PM) timhunt: I can answer that.
(5:57:58 PM) timhunt: So, admin/settings.php is the script that drives the whole process.
(5:58:39 PM) timhunt: That just calls the method admin_settingpage::output_html defined in lib/adminlib.php
(5:59:17 PM) timhunt: And that basically does
foreach($this->settings as $setting) {
// ...
$return .= $setting->output_html($data);
}
(5:59:44 PM) timhunt: $setting is an instance of one of the admin_setting classes. Each one can generate its own HTML.
(6:01:15 PM) timhunt: But most of them call the format_admin_setting function (also in adminlib.php) to generate most of the HTML structure.

=======

I hope this helps you David?

Cheers

Mary

In reply to David Scotson

Re: Getting rid of tags

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

Hi David,

If you had the option of changing the Login form ../login/login_form.php how whould you rewrite this?

<?php
  } ?>
    <h2><?php print_string("returningtosite") ?></h2>
      <div class="subcontent loginsub">
        <div class="desc">
          <?php
            print_string("loginusing");
            echo '<br/>';
            echo '('.get_string("cookiesenabled").')';
            echo $OUTPUT->help_icon('cookiesenabled');
           ?>

How would you like to style it had you the option?

In reply to Mary Evans

Re: Getting rid of tags

by David Scotson -
I've pushed my file to github:

https://github.com/ds125v/moodle-theme_bootstrap_renderers/blob/master/replace/login/index_form.html

and attached a screenshot.

As per my usual plan I'm trying to stick close to both the Moodle standard and the Bootstrap 3 standard with a bit of creativity applied where they clash. I think login screens might be one of those places where people would most like to customise and 'brand' things.
Attachment login.png