Forums | Mahara Community

Developers /
Moving a block to the top of the block chooser: Core Code Change?

anonymous profile picture
Account deleted
Posts: 32

05 August 2015, 4:12

Does the core code need to be changed to move a block from the General tab, up to the top by the image block?


Edits to this post:
Aaron Wells's profile picture
Posts: 896

05 August 2015, 10:41

Hi Marylena,

Prior to 15.04 the blocks at the top of the block chooser were hard-coded in place as part of the theme. (And the other blocks were ordered in their categories by alphabetical order of their system name.)

In 15.04 we changed this to a more flexible database-based system. So now, if you look in the database table blocktype_installed_category you'll see every installed blocktype, which block chooser category it goes in, and what order it goes in. The blocktypes that are up at the top of the block chooser are in the category called "shortcut".

If you're writing a 3rd-party block plugin, you can modify you're block's "get_categories()" method to change its category to "shortcut".

If you want to customize the order of Mahara's built-in blocks, you can just change stuff around in the blocktype_installed_category table, although some of your changes might get overwritten during upgrades (the block's category gets re-synced to its "get_categories()" method whenever the block's version goes up). So if you wanted to make it really stick, you'd need to alter the "get_categories()" method of the block.



2 results