Layout Course

Layout Course

על ידי Luis Sola Ruiz בתאריך
מספר תגובות: 5

Hello everyone, I am creating a new block for a course.

In this block I have a link to another page inside my block "test.php". I am trying to set the layout of the course that I come from with $PAGE->set_pagelayout('course'); but I supposed I need the id of a course. is there a solution for this?

I checked https://docs.moodle.org/38/en/Block_layout but I will not have access to config.php of moodle in the future. 

Thanks.

ממוצע דרוגים: -
בתגובה ל: Luis Sola Ruiz

Re: Layout Course

על ידי Jon Bolton בתאריך
תמונה של Particularly helpful Moodlers תמונה של Testers
If this is a block you’re coding yourself, you’ll probably get help in the General Developers forum.

If not, you could consider using the FilterCodes plugin which will easily return the course id of the current course.
בתגובה ל: Luis Sola Ruiz

Re: Layout Course

על ידי Howard Miller בתאריך
תמונה של Core developers תמונה של Documentation writers תמונה של Particularly helpful Moodlers תמונה של Peer reviewers תמונה של Plugin developers
In the block where you generate the link you know what the course id is, so add it as a parameter in the link to test.php

So, something like...

$link = new moodle_url('/blocks/luis_thing/test.php', ['courseid' => $PAGE->course->id]);

...and in test.php

$courseid = required_param('courseid', PARAM_INT);
בתגובה ל: Howard Miller

Re: Layout Course

על ידי Luis Sola Ruiz בתאריך
Thanks Howard for your reply. You were totally right, in this way I can identify the course where I come from.

But as you can see there is not the same layout.

In the course:                                                            Clicking in the link inside my block that redirect to another page: