N. F.
N. F.

Reputation: 901

How to run some function during installation of a moodle block?

I am just wondering if there is any way to run some custom function when a block is being installed? I can see that there is after_installation() function used in a block, but there is no function declaration in the super class block_base.

Upvotes: 2

Views: 162

Answers (1)

davosmith
davosmith

Reputation: 6317

In db/install.php (inside your block's folder) put a function called xmldb_block_BLOCKNAME_install(). You should probably return true at the end of this, but I'd have to double check to see if that is required.

You can put whatever you want inside the function. This works for all different plugin types in Moodle.

Upvotes: 2

Related Questions