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

Block regions are not showing at proper times

    XMLWordPrintable

    Details

    • Affected Branches:
      MOODLE_21_STABLE

      Description

      Reference code:

      $hassidepost = (empty($PAGE->layout_options['noblocks']) && $PAGE->blocks->region_has_content('side-post', $OUTPUT));
      ...
      $showsidepost = ($hassidepost && !$PAGE->blocks->region_completely_docked('side-post', $OUTPUT));
      ....
      if ($showsidepre && !$showsidepost) {
          $bodyclasses[] = 'side-pre-only';
      } else if ($showsidepost && !$showsidepre) {
          $bodyclasses[] = 'side-post-only';
      } else if (!$showsidepost && !$showsidepre) {
          $bodyclasses[] = 'content-only';
      }

      So, two problems with showing or not showing block regions. First is that region_has_content() always returns true when the user is editing and if the user can edit blocks. The comment in the function says it does this so that all regions are visible when moving the block, but this still prints the region even though it's completely empty of blocks and empty of "move to here" icons/widgets. The attached patch also checks the $this->moving block flag and only forces the return of true if the user is currently moving the block.

      Second problem is that region_completely_docked ignores blocks that have empty content. So, if you have no blocks in say, the left column and then you add a empty HTML block to the left column, then the left column will never be visible because the body class will have side-post-only class. The patch addresses this by removing the check if the block is empty or not. The region_has_content() handles empty blocks.

      In the end though, I'm not sure if my fixes are 100% correct and could possibly introduce regression. Please review.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              moodle.com moodle.com
              Reporter:
              bushido Mark Nielsen
              Participants:
              Component watchers:
              Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Peter Dias, Sujith Haridasan, Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Ilya Tregubov, Sara Arjona (@sarjona), Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Ilya Tregubov, Sara Arjona (@sarjona)
              Votes:
              2 Vote for this issue
              Watchers:
              5 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: