Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-69464

Option to allow HTML in the page headings (skip applying format_string)

    XMLWordPrintable

Details

    • MOODLE_39_STABLE
    • MOODLE_310_STABLE
    • Hide

      1. Edit source code of any page and modify the $PAGE->set_heading() call, for example in course/index.php replace it with:

      $PAGE->set_heading(format_string($heading) . ' <a href="/">EDIT</a>', false);
      

      2. Open this page in the browser
      3. Make sure you can see an "EDIT" link next to the heading
      4. Modify the code again to remove the second argument ("false")
      5. Open the page in the browser - you will see text EDIT without link

      Show
      1. Edit source code of any page and modify the $PAGE->set_heading() call, for example in course/index.php replace it with: $PAGE->set_heading(format_string($heading) . ' <a href="/">EDIT</a>', false); 2. Open this page in the browser 3. Make sure you can see an "EDIT" link next to the heading 4. Modify the code again to remove the second argument ("false") 5. Open the page in the browser - you will see text EDIT without link

    Description

      Some related issues MDL-42339 (fixed), MDL-29240 (closed as inactive)

      When calling $PAGE->set_heading() it calls the format_string() unconditionally. If $CFG->formatstringstriptags is set to on (which is default), all tags are removed from the page heading.

      We need to be able to add a "pill" or "edit" icon to the heading and it is not possible because of this. We also can't change the default behavior (applying format_string()) because a lot of place expect it to be present. So how about adding a parameter $applyformatting = true

      With this change we can call:

      $heading = format_string(...);
      $pill = ' <span class="badge badge-secondary">New</span>';
      $PAGE->set_heading($heading . $pill, false);
      

      Attachments

        Issue Links

          Activity

            People

              marina Marina Glancy
              marina Marina Glancy
              Paul Holden Paul Holden
              Andrew Lyons Andrew Lyons
              Janelle Barcega Janelle Barcega
              Amy Groshek, David Scotson, Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Ilya Tregubov, Laurent David, Sara Arjona (@sarjona)
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                9/Nov/20

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 2 hours, 21 minutes
                  2h 21m