Skip to content

Instantly share code, notes, and snippets.

@jibran
Created April 21, 2015 06:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jibran/b646dbc4177b7f044fd1 to your computer and use it in GitHub Desktop.
Save jibran/b646dbc4177b7f044fd1 to your computer and use it in GitHub Desktop.
Create a custom block.
<?php
function my_module_update_xxxx () {
$query = db_insert('block_custom')
->fields(array(
'body' => 'Some markup',
'info' => 'Some title for info',
'format' => 'rich_text',
));
$bid = query->execute();
db_insert('block')
->fields(array(
'module' => 'block',
'delta' => $bid,
// Active theme.
'theme' => 'my_theme',
'status' => 1,
'weight' => 0,
// It places the block in content region.
'region' => 'content',
// It will be visible on all pages.
'pages' => '',
// It will use the info set above as a title.
'title' => '',
))
->execute();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment