Override enroll course page

Override enroll course page

di Melqui Chaves -
Numero di risposte: 4

Hi,

I'm trying to change the page where the user is redirected when he is not enrolled into the course.
I can use the config.php theme to change the mydashboard to a mustache template that i like, for instance. But i can't see a way to do this with this page in particular.

It's possible to archieve this without appeal to dark magic?


Thanks!

Media dei voti: -
In riposta a Melqui Chaves

Re: Override enroll course page

di Mary Evans -
Immagine Core developers Immagine Documentation writers Immagine Peer reviewers Immagine Plugin developers Immagine Testers

We need to know more about the version of Moodle and also your theme, as all these things make a difference to the answer you need.

Redirect pages where easy to change in older versions of Moodle now all the fun has been taken away from us and so the redirect does whatever it is told to do by moodle.

What would you like it to do...wave a flag and say something funny?

We are not magicians but we do like a laugh!

Mary

In riposta a Mary Evans

Re: Override enroll course page

di Melqui Chaves -

Hi Mary!

Thanks for the answer!


Sorry, i've totaly forget to say what im using. D:

The version is 3.3 and i'm building a theme that is child of Boost theme.


So, i have this situation that i want to make changes into the page where the user enrol himself into a course or redirect this unnenrolled user to another page that will show the things that i want.


I want to make this because i need to show more information about the course to the user before he enroll himself. Another reason it's because we have a LOT of subscription methods into the course! So there's a lot of fields that arent relevants for the user to enrol, instead i'll put just one field where the user writes his subscription key.


Actualy, i've been able to change the page, but i've accomplished this using obscure things that i can regret later.
Basically, i know that "columns2.php" it's responsable to output the main content that renderers the enrolpage. So, in coluns2.mustache i have:

<section id="region-main" {{#hasblocks}}class="has-blocks"{{/hasblocks}}>
     <div class="card card-block">
         {{#hasregionmainsettingsmenu}}
              <div class="region_main_settings_menu_proxy"></div>
         {{/hasregionmainsettingsmenu}}
         {{{ output.course_content_header }}}
         {{{ output.main_content }}}
         {{{ output.course_content_footer }}}
     </div>
</section>


output.main_content - It's responsable to show the content of the enrolpage and everything else. So i did this in columns2.php:

if($PAGE->url->get_path() == '/enrol/index.php'){
    echo $OUTPUT->render_from_template('theme_thoth/enrol', $templatecontext);
}else{
    echo $OUTPUT->render_from_template('theme_thoth/columns2', $templatecontext);
}


So, if i'm in /enrol/index.php  url, then this will take enrol.mustache has template.
This didn't solve my situation, because in "enrol.mustache" it's necessary to use "output.main_content" or the page don't renders. So, i did this:


<section id="region-main" {{#hasblocks}}class="has-blocks"{{/hasblocks}}>
     <div class="card card-block">
         {{#hasregionmainsettingsmenu}}
              <div class="region_main_settings_menu_proxy"></div>
         {{/hasregionmainsettingsmenu}}
         {{{ output.course_content_header }}}
         <!-- {{{ output.main_content }}} -->
         {{{ output.course_content_footer }}}
     </div>
</section>


You see, now i can put wharever i want into the enrol page, but you also can see my concerns with dark magic, those kind off stuff allways comes with a price later. Here in Brazil we call this kind of stuff of "Gambiarra". And if you do like a laugh, i sugest search of this on google images.

I wan't to know if there's a different solution for this. Because what i've done doesn't appeart to be the correct way...

Thanks and sorry if i'm wasn't clear or much objective! 

In riposta a Melqui Chaves

Re: Override enroll course page

di Mary Evans -
Immagine Core developers Immagine Documentation writers Immagine Peer reviewers Immagine Plugin developers Immagine Testers

Hi Melqui, 

I am so sorry for missing your reply to your request for help.

We used to do this in the older 2.5 themes, in the login page. It was considered a "Hack" then so nothing new. If it works for you then it's OK.

However, I am sure that with a little more thought a better solution may come to you. Think out of the box...an alternative. For example have you thought to use the Course summary to highlight the points you want the student to be aware of before they enrol.

Mary