I need to insert an html code into a content block. As the html code has some javascript links and css, I've done a module to include all the references in the .info file. The problem is that I don't know how to insert the html code in the .module file.

This is the html code:

    <link rel="icon" type="image/png" href="favicon.ico">
    <title>Aldizkari Elektronikoa</title>
  <meta charset="UTF-8" />

  <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="apple-mobile-web-app-status-bar-style" content="black">
  <meta name="format-detection" content="telephone=no">
  <meta http-equiv="cleartype" content="on">
  <meta name="description" content="Aldizkari Elektronikoa"/>
  <meta name="keywords" content="" />
  <meta name="author" content="" />
<!-- Development mode -->
  <link rel="stylesheet" href="assets/font-awesome/css/font-awesome.min.css">
  <link rel="stylesheet" href="assets/stylesheets/style.css">
  <link rel="stylesheet" href="assets/stylesheets/secciones.css">
  <link rel="stylesheet" href="assets/stylesheets/mediaQuery.css">

  <body class="no-js">

    <section id="sec">
      <div id="secciones"></div>
      <div id="secciones-control"></div>

    <script src="assets/libraries/jquery-1.9.1.js"></script>
    <script src="assets/libraries/mustache.js"></script>
    <script src="assets/libraries/jquery.imagesloaded.min.js"></script>
    <script src="assets/libraries/jquery.mobile-1.3.1.min.js"></script>
    <script src="assets/libraries/verge.min.js"></script>
<!-- Development mode -->
    <script src="assets/data/langs.js"></script>
    <script src="assets/data/services.js"></script>
        <script src="assets/data/events.js"></script>
    <script src="assets/data/templates.js"></script>


As you can see most of the code are references to javascripts and css. But what I need is to include the to the module, because this is the part that shows what I need form my page.

Do you know if the is any hook for this? Or can I do in an other way to add this html structure to the content block?

I hope you can help me,


2 Answers 2


You can always create a block in your module. You'll need hook_block_info, hook_block_view.


function hook_block_info() {
// This example comes from node.module.
$blocks['syndicate'] = array(
'info' => t('Syndicate'),
'cache' => DRUPAL_NO_CACHE,

return $blocks;

Then in hook_block_view:

function hook_block_view($delta = '') {
// This example is adapted from node.module.
$block = array();

switch ($delta) {
  case 'syndicate':
    $block['subject'] = t('Syndicate');
    $block['content'] = myfunction();
  return $block;

Then you just need to return what ever out put you want in myfunction, and you should be set. Check out the links for more info, full block api is also here.

  • 1
    I think you're missing a ; after return $block in hook_block_view - for anyone who copies and pastes.
    – Geoff
    Jun 10, 2014 at 15:10

and attach the js and css

function my_module_block_view($delta = '')
  if($delta == 'my_module_delta')
    $block = array
      'subject' => t('My block title'),
      'content' => array
        '#markup' => '<p>' . t('This is some text that will go in the block.') . '</p>',
        '#attached' => array
          'js' => array('path/to/file.js'),
          'css' => array('path/to/file.css'),
    return $block;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.