Override enroll course page

Re: Override enroll course page

by Melqui Chaves -
Number of replies: 2

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! 

Average of ratings: Useful (1)
In reply to Melqui Chaves

Re: Override enroll course page

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of 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