How to add a html content block to right column of Eguru theme?

How to add a html content block to right column of Eguru theme?

by Tri Nguyen Dung -
Number of replies: 5

Hi supporter,

I want to add a new html block to the right (column 3) of Eguru theme. Below is an example:

  • My html block looks like this:

<div style="margin-bottom: 20px;">
   <img style="width: 100%;" src="http://elearning-medvnu.edu.vn/theme/eguru/img/ad2.png"/>
</div>

  • And I want my html div placed inside the column 3 just look like this:
    My div contain an image was put inside the site-post of column 3

I also find the the code of file Moodle\theme\eguru\layout\columns3.php. And see that, after this line 84, I can do something to add the html block:

<?php echo $OUTPUT->blocks('side-post', 'span3'); ?>

But it didn't work out because the div doesn't stay inside the column 3.


Please help me to find a solution that can help me to custom adding html block to column 3 of Eguru them.

  • I'm using Moodle 2.7.2
  • Eguru version: 2016110400
  • Release: v1.3
  • Eguru backed file name: theme_eguru_moodle36_2019012601.zip


Best regards,

Tri Nguyen




Average of ratings: -
In reply to Tri Nguyen Dung

Re: How to add a html content block to right column of Eguru theme?

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

To specifically solve this in the way you want to, you need to:

  • Know about object orientated PHP.
  • Edit the theme's overridden core renderer and transpose the 'blocks' method that you'll find in the 'core_renderer' in the '/lib/outputrenders.php'.
  • Then edit that method to add your markup to the output when 'side-post' is used as a '$region' parameter value.  You will need to read all of the code that the method calls and then decide the best place, which could mean overriding the 'blocks_for_region' method instead of 'blocks'.

In reply to Gareth J Barnard

Re: How to add a html content block to right column of Eguru theme?

by Tri Nguyen Dung -

Thanks Gareth J Barnard,

I have update the function blocks and the archived the goal. I will try learn object orientated PHP.

Best regards,

Tri

In reply to Tri Nguyen Dung

Re: How to add a html content block to right column of Eguru theme?

by Jon Bolton -
Picture of Particularly helpful Moodlers Picture of Testers

Is there a reason you’re editing the php file and not just turning editing on and adding an HTML block?

I’m not familiar with the Eguru theme, but by default you can add HTML blocks (and many other types of block) to a course very easily.

And you can also make it appear throughout the site.

In reply to Jon Bolton

Re: How to add a html content block to right column of Eguru theme?

by Tri Nguyen Dung -

Hi Jon Bolton,

To add a personal html block to aside bar, it is not simple as adding an html to a course. Some users won't see the html block added because the course doesn't belong to them. Also, if the html contains images, it won't look like which I want it be in the aside bar.

Thus by making this way, I will override all the rules and make my html block appear among all pages as I want.

Best regards,

Tri

In reply to Jon Bolton

Re: How to add a html content block to right column of Eguru theme?

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

That is exactly what I was thinking saying too Jon...

Obviously this is not what the OP had in mind.

Mary