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

Switch block's columns when course is set to RTL Mode (Hebrew, Arabic or Farsi languages)

    Details

      Description

      Block columns should switch sides in RTL Mode (Hebrew, Arabic, Farsi... languages)

        Gliffy Diagrams

          Issue Links

            Activity

            Hide
            nadavkav Nadav Kavalerchik added a comment - - edited

            @Mary,
            Please have a look

            Also, It seems, I should apply a similar patch to all themes since they have similar layout/general.php file with some differences in each theme.

            What do you think? Is there a more elegant way to do this?

            Show
            nadavkav Nadav Kavalerchik added a comment - - edited @Mary, Please have a look Also, It seems, I should apply a similar patch to all themes since they have similar layout/general.php file with some differences in each theme. What do you think? Is there a more elegant way to do this?
            Hide
            lazydaisy Mary Evans added a comment -

            I've just assigned this to you.

            The body class looks OK but not sure about the changes in the main layout for region-pre and region-post. Why not do something like...

            IF has side pre AND is rtl
            THEN OUTPUT side post

            Because all you want to do is swap sides isn't it?

            Show
            lazydaisy Mary Evans added a comment - I've just assigned this to you. The body class looks OK but not sure about the changes in the main layout for region-pre and region-post. Why not do something like... IF has side pre AND is rtl THEN OUTPUT side post Because all you want to do is swap sides isn't it?
            Hide
            nadavkav Nadav Kavalerchik added a comment -

            I got funny errors when i tried

            IF has side pre AND is rtl 
            THEN OUTPUT side post

            $OUTPUT->blocks_for_region('side-pre'); did not display anything when I was in RTL and "has side post".
            Maybe I was not considering something.
            I'd love if you or someone else can suggest a better code

            How about the other themes, Am i right?

            Show
            nadavkav Nadav Kavalerchik added a comment - I got funny errors when i tried IF has side pre AND is rtl THEN OUTPUT side post $OUTPUT->blocks_for_region('side-pre'); did not display anything when I was in RTL and "has side post". Maybe I was not considering something. I'd love if you or someone else can suggest a better code How about the other themes, Am i right?
            Hide
            lazydaisy Mary Evans added a comment -

            Each theme would need to be changed separately, as they all use their own particular layout file, which will be a big job to do. However, it might be easier to do this in moodle/lib/outputrenderers.php then this could be done in Moodle core and each theme would output the relevent code as required. Which would...if this can be done, make for a better solution.

            So what we need is to create a function that recognises that the site is dir-rtl so output for side-pre = $OUTPUT->blocks_for_region('side-post');
            and
            output for side-post = $OUTPUT->blocks_for_region('side-pre');

            But I don't know enough about Moodle to know if this can be done, or if it is in the correct place to do this.

            Does this sound feasible?

            Show
            lazydaisy Mary Evans added a comment - Each theme would need to be changed separately, as they all use their own particular layout file, which will be a big job to do. However, it might be easier to do this in moodle/lib/outputrenderers.php then this could be done in Moodle core and each theme would output the relevent code as required. Which would...if this can be done, make for a better solution. So what we need is to create a function that recognises that the site is dir-rtl so output for side-pre = $OUTPUT->blocks_for_region('side-post'); and output for side-post = $OUTPUT->blocks_for_region('side-pre'); But I don't know enough about Moodle to know if this can be done, or if it is in the correct place to do this. Does this sound feasible?
            Hide
            lazydaisy Mary Evans added a comment - - edited

            Thinking about this some more...perhaps something simpler may work...

            in moodle/blocklib.php we can re-define the BLOCKS

            from this

            /**#@+
             * Default names for the block regions in the standard theme.
             */
            define('BLOCK_POS_LEFT',  'side-pre');
            define('BLOCK_POS_RIGHT', 'side-post');
            /**#@-*/

            to this

            /**#@+
             * Default names for the block regions in the standard theme.
             */
            if $PAGE->right_to_left(){
                define('BLOCK_POS_LEFT',  'side-post');
                define('BLOCK_POS_RIGHT', 'side-pre');
            }else{
                define('BLOCK_POS_LEFT',  'side-pre');
                define('BLOCK_POS_RIGHT', 'side-post');
            }
            /**#@-*/

            If only it was that simple!!!

            Show
            lazydaisy Mary Evans added a comment - - edited Thinking about this some more...perhaps something simpler may work... in moodle/blocklib.php we can re-define the BLOCKS from this /**#@+ * Default names for the block regions in the standard theme. */ define('BLOCK_POS_LEFT', 'side-pre'); define('BLOCK_POS_RIGHT', 'side-post'); /**#@-*/ to this /**#@+ * Default names for the block regions in the standard theme. */ if $PAGE->right_to_left(){ define('BLOCK_POS_LEFT', 'side-post'); define('BLOCK_POS_RIGHT', 'side-pre'); }else{ define('BLOCK_POS_LEFT', 'side-pre'); define('BLOCK_POS_RIGHT', 'side-post'); } /**#@-*/ If only it was that simple!!!
            Hide
            nadavkav Nadav Kavalerchik added a comment -

            Thank you for the ideas.
            I will look into them

            Show
            nadavkav Nadav Kavalerchik added a comment - Thank you for the ideas. I will look into them
            Hide
            lazydaisy Mary Evans added a comment -

            I have just tried this...

            /**#@+
             * Default names for the block regions in the standard theme.
             */
            if (right_to_left()) {
                define('BLOCK_POS_LEFT',  'side-post');
                define('BLOCK_POS_RIGHT', 'side-pre');
            }else{
                define('BLOCK_POS_LEFT',  'side-pre');
                define('BLOCK_POS_RIGHT', 'side-post');
            }
            /**#@-*/

            But it did not appear to do anything...so we need to find what happens to the blocks after this section...ummm

            Show
            lazydaisy Mary Evans added a comment - I have just tried this... /**#@+ * Default names for the block regions in the standard theme. */ if (right_to_left()) { define('BLOCK_POS_LEFT', 'side-post'); define('BLOCK_POS_RIGHT', 'side-pre'); }else{ define('BLOCK_POS_LEFT', 'side-pre'); define('BLOCK_POS_RIGHT', 'side-post'); } /**#@-*/ But it did not appear to do anything...so we need to find what happens to the blocks after this section...ummm
            Hide
            lazydaisy Mary Evans added a comment -

            Hi Nadav,
            I think I have cracked it! This works just as you want it to.

                            <?php if ($hassidepre) { ?>
                            <div id="region-pre" class="block-region">
                               <div class="region-content">
                                  <?php
                                  if (right_to_left()) {
                                      echo $OUTPUT->blocks_for_region('side-post');
                                  } else {
                                      echo $OUTPUT->blocks_for_region('side-pre');
                               } ?>
             
                               </div>
                            </div>
                            <?php } ?>
             
                            <?php if ($hassidepost) { ?>
                            <div id="region-post" class="block-region">
                               <div class="region-content">
                                  <?php
                                  if (right_to_left()) {
                                      echo $OUTPUT->blocks_for_region('side-pre');
                                  } else {
                                      echo $OUTPUT->blocks_for_region('side-post');
                               } ?>
                               </div>
                            </div>
                            <?php } ?>

            Nothing else is needed...no need to fix bodyclasses as the container stays and is styled as it is regardless of content, since the only thing that is moving is the content $OUTPUT so this is simplcity itself, and one wonders why this has not been done before.

            Anyway I have developed a new theme called 'rtlbase' which I have just added this fix to. I'll email you a copy to test.
            Cheers
            Mary

            Show
            lazydaisy Mary Evans added a comment - Hi Nadav, I think I have cracked it! This works just as you want it to. <?php if ($hassidepre) { ?> <div id="region-pre" class="block-region"> <div class="region-content"> <?php if (right_to_left()) { echo $OUTPUT->blocks_for_region('side-post'); } else { echo $OUTPUT->blocks_for_region('side-pre'); } ?>   </div> </div> <?php } ?>   <?php if ($hassidepost) { ?> <div id="region-post" class="block-region"> <div class="region-content"> <?php if (right_to_left()) { echo $OUTPUT->blocks_for_region('side-pre'); } else { echo $OUTPUT->blocks_for_region('side-post'); } ?> </div> </div> <?php } ?> Nothing else is needed...no need to fix bodyclasses as the container stays and is styled as it is regardless of content, since the only thing that is moving is the content $OUTPUT so this is simplcity itself, and one wonders why this has not been done before. Anyway I have developed a new theme called 'rtlbase' which I have just added this fix to. I'll email you a copy to test. Cheers Mary
            Hide
            nadavkav Nadav Kavalerchik added a comment -

            Beautiful

            Have you tested it with pages that has only side-pre or only side-post?
            I remember i had issues with those situation while i was getting to the final code to work smoothly.

            btw, see if you can change the rtlbase to basertl, so it will be listed just after the base theme on the file system.
            might be nicer?

            Still, i guess i will have to go through the themes and patch them too.

            Show
            nadavkav Nadav Kavalerchik added a comment - Beautiful Have you tested it with pages that has only side-pre or only side-post? I remember i had issues with those situation while i was getting to the final code to work smoothly. btw, see if you can change the rtlbase to basertl, so it will be listed just after the base theme on the file system. might be nicer? Still, i guess i will have to go through the themes and patch them too.
            Hide
            lazydaisy Mary Evans added a comment -

            I'll do some more testing.

            Yes to name change...that makes sense

            Show
            lazydaisy Mary Evans added a comment - I'll do some more testing. Yes to name change...that makes sense
            Hide
            salvetore Michael de Raadt added a comment -

            Thanks for working on this, Nadav and Mary.

            Show
            salvetore Michael de Raadt added a comment - Thanks for working on this, Nadav and Mary.
            Hide
            marina Marina Glancy added a comment -

            We have detected that this issue has been inactive for over two years and also did not collect many votes. It is possible that it has been already implemented in a more recent version of Moodle, or it is not highly demanded. There are unlimited number of ways Moodle functinality can be expanded and improved but we would like to concentrate on the features that will benefit majority of users, and which can not be implemented as plugins. If you have a suggestion for improving Moodle core, and there is no open issue for it in the tracker, please start a new forum discussion to see how many other users agree with you, and then create a new issue providing as many details as possible.

            ==BLK2YIMP20141121==

            Show
            marina Marina Glancy added a comment - We have detected that this issue has been inactive for over two years and also did not collect many votes. It is possible that it has been already implemented in a more recent version of Moodle, or it is not highly demanded. There are unlimited number of ways Moodle functinality can be expanded and improved but we would like to concentrate on the features that will benefit majority of users, and which can not be implemented as plugins. If you have a suggestion for improving Moodle core, and there is no open issue for it in the tracker, please start a new forum discussion to see how many other users agree with you, and then create a new issue providing as many details as possible. ==BLK2YIMP20141121==
            Hide
            lazydaisy Mary Evans added a comment - - edited

            This got fixed in MDL-32479
            So technically this should have been closed in 2012.

            Show
            lazydaisy Mary Evans added a comment - - edited This got fixed in MDL-32479 So technically this should have been closed in 2012.

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: