Moodle Block Upload

Moodle Block Upload

by Robert Bryan -
Number of replies: 3

Hi,

I am having problems with uploading my own block into my Moodle site. I have copied my block files into the block folder of the Moodle directory, however when I go to see if the file has been loaded, there is no notification confirming the block has been uploaded. Also when I look at the XMLDB editor page under site administrator, the block isn't listed. Can someone help please!

Thanks in advance

Rob 

Average of ratings: -
In reply to Robert Bryan

Re: Moodle Block Upload

by Sam Chaffee -
Picture of Core developers

Hi Rob,

Do you have all the required files for the block? E.g., for block_example:

  • blocks/example/block_example.php
  • blocks/example/db/access.php
  • blocks/example/lang/en/block_example.php
  • blocks/example/version.php

Where blocks in the above is the Moodle blocks directory.

See https://docs.moodle.org/dev/Blocks#Ready.2C_Set.2C_Go.21 for more information.

In reply to Sam Chaffee

Re: Moodle Block Upload

by Robert Bryan -

This is a picture of my file structure in Netbeans

Hi Sam, Thanks for getting back to me. I have copied a picture of my file structure from netbeans. I have also loaded my block.php file as well, which I have built through following the online developer documentation. Can you you have a look at it for me, and let me know what I am missing. I need to get it loaded, so that I start playing around with it.

Thanks

Rob

In reply to Robert Bryan

Re: Moodle Block Upload

by Sam Chaffee -
Picture of Core developers

Hi Rob,

Take a look again at the documentation and the code for one of the core blocks, like https://github.com/moodle/moodle/tree/MOODLE_30_STABLE/blocks/blog_tags.

A couple things I noticed, though, are that your block-qeims.php should be block_qeims.php (underscore instead of a dash) and it should only contain the class definition, nothing else. Any HTML you want to appear in the block should be returned from the get_content() method.

Styles for your block should be added via a styles.css file and the lang file should be in lang/en/block_qeims.php.

Cheers,

Sam