Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-38856 META: Issues around Bootstrapbase and Clean theme
  3. MDL-40065

Bootstrap Theme always sends content to "side-pre", even when there isn't one

    Details

    • Type: Sub-task
    • Status: Closed
    • Priority: Blocker
    • Resolution: Fixed
    • Affects Version/s: 2.5, 2.6
    • Fix Version/s: 2.5.1
    • Component/s: Themes
    • Labels:
    • Testing Instructions:
      Hide
      1. Select the 'Clean' theme.
      2. Logout and go to the login screen.
      3. Confirm that the layout is correct with no blocks and one content area that fills the screen 100% - FireBug should show that the area does. This is a test for 'column1.php'.
      4. Login and go to the 'Purge All Caches' screen because it uses the 'admin' layout as defined in 'bootstrapbase/config.php' which uses 'column2.php'.
      5. Confirm that with a LTR language the blocks are on the left.
      6. Switch to a RTL language and confirm the blocks are the same but are now on the right.
      7. Temporarily edit 'bootstrapbase/config.php' and change the 'side-pre' to 'side-post' value for the 'admin' layout for both the 'regions' and 'defaultregion' array keys (save changes).
      8. Refresh the 'Purge All Caches' page, still with the RTL language enabled, confirm that the blocks are now on the left and no errors occur.
      9. Switch back to a LTR language and confirm the same blocks are now on the right and no errors occur.
        END TEST
      Show
      Select the 'Clean' theme. Logout and go to the login screen. Confirm that the layout is correct with no blocks and one content area that fills the screen 100% - FireBug should show that the area does. This is a test for 'column1.php'. Login and go to the 'Purge All Caches' screen because it uses the 'admin' layout as defined in 'bootstrapbase/config.php' which uses 'column2.php'. Confirm that with a LTR language the blocks are on the left. Switch to a RTL language and confirm the blocks are the same but are now on the right. Temporarily edit 'bootstrapbase/config.php' and change the 'side-pre' to 'side-post' value for the 'admin' layout for both the 'regions' and 'defaultregion' array keys (save changes). Refresh the 'Purge All Caches' page, still with the RTL language enabled, confirm that the blocks are now on the left and no errors occur. Switch back to a LTR language and confirm the same blocks are now on the right and no errors occur. END TEST
    • Affected Branches:
      MOODLE_25_STABLE, MOODLE_26_STABLE
    • Fixed Branches:
      MOODLE_25_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      wip-MDL-40065-master_4

      Description

      As requested by Damyon Wiese, this is now a late addition to MDL-39824 as it ha been integrated. It does solve the original issue too and impoves the solution in MDL-39824 with less code changes and smaller layout files.

      Old description:

      There is an error in the logic of bootstrapbase and clean themes layout. general.php which results in side-pre always being output, even if the $THEME->layouts for the page affected excludes side-pre.

      Lines 143-162 have the error in bootstrapbase/layout/general.php, and lines 172 to 202 have the error in the clean theme.

      The logic error is that the code tests to see if $layout is not content-only. If true then the code renders the html for pre-and-post or for side-pre-only, and drops by error into "if (!right_to_left())" regardless of what $layout is set to.

      Therefore if $layout is set to side-post-only there is no HTML code generated, but "echo $OUTPUT->blocks_for_region('side-pre')" is executed regardless.

      One possible fix is to change

                      if (!right_to_left()) {
                          echo $OUTPUT->blocks_for_region('side-pre');
                      } else if ($hassidepost) {
                          echo $OUTPUT->blocks_for_region('side-post');
                      } ?>
      

      to

                      if(!$layout === 'side-post-only') {
                          if (!right_to_left()) {
                              echo $OUTPUT->blocks_for_region('side-pre');
                          } else if ($hassidepost) {
                              echo $OUTPUT->blocks_for_region('side-post');
                          }
                      }
      

      However, it is probably better to fix the logic completely so that the echo $OUTPUT->blocks_for_region only occurs when $layout is 'pre-and-post' or 'side-pre-only'

      How to test:

      Turn on Debug to Developer and Theme Design Mode on

      Copy the entire section of $THEME->layouts from bootstrapbase/config.php and paste into config.php of clean/config.php

      In config.php of theme standard, and theme clean (please alter both!), change the front page layout to:

          // The site home page.
          'frontpage' => array(
              'file' => 'general_frontpage.php',
              'regions' => array('side-pre'),
              'defaultregion' => 'side-pre',
              'options' => array('nonavbar'=>true),
      

      Purge caches after saving the two config.php files

      Select Site Admininstration / Appearance / Theme / Theme Selector and select Clean theme. Go to the front page (ALL should be OK)

      Select Site Admininstration / Appearance / Theme / Theme Selector and select Standard theme. Go to the home page (ALL should be OK)

      Re edit the two config.php $THEME->layout to:

          // The site home page.
          'frontpage' => array(
              'file' => 'general_frontpage.php',
              'regions' => array('side-post'),
              'defaultregion' => 'side-post',
              'options' => array('nonavbar'=>true),
      

      Purge caches again

      Go to front page - all is still OK

      Select Site Admininstration / Appearance / Theme / Theme Selector and select Clean theme. Go to the front page

      Now you get the Theme header but before you get to the main body Moodle throws an exception - "Coding error detected, it must be fixed by a programmer: Trying to reference an unknown block region side-pre"

      Fix the logic error in clean/layout/general.php

      Purge all caches

      The error should be corrected.

      NOTE: There appears to be another bug but I will raise a second issue for that one. The problem is, if blocks are configured to appear in side-post, then when the $THEME-layout for a page says only use side-pre, the blocks disappear when using theme Clean. This doesn't happen with theme Standard. Please link this other issue as it may be related.

        Gliffy Diagrams

          Attachments

          1. MDL-40065_2cols.jpg
            MDL-40065_2cols.jpg
            14 kB
          2. mdl-40065-tt.png
            mdl-40065-tt.png
            13 kB
          3. spost-ltr.png
            spost-ltr.png
            56 kB
          4. spost-rtl.png
            spost-rtl.png
            52 kB
          5. spre-ltr.png
            spre-ltr.png
            54 kB
          6. spre-rtl.png
            spre-rtl.png
            51 kB

            Issue Links

              Activity

                People

                • Votes:
                  1 Vote for this issue
                  Watchers:
                  15 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Fix Release Date:
                    8/Jul/13