I am using drupal - 7.
I wanted to embed <script>
tags for Retargeting tag into each page of the Website, between the <body> </body>
tags.
I am new to Drupal. I am trying to create custom block module for this.
I have created custom module to place tags into custom block. I am not sure what I have done is right or wrong. Can any one help me with this?
I just wanted to add script like this into each page for Retargeting tags for campaigns
<script async src="http://i.simpli.fi/dpx.js?cid=0&segment=Segment+Name&campaign_id=0"></script>
I have added script tag into my js file which I have called from .info file. In my .info file I called;
scripts[] = MyCustomBlock.js
This is the code for my custom block module.
/** * Implements hook_help(). * * Displays help and module
information. * * @param path * Which path of the site we're
using to display help * @param arg * Array that holds the current
path as returned from arg() function */
function MyCustomBlock_help($path, $arg) {
switch ($path) {
case "admin/help#MyCustomBlock":
return '<p>' . t("Displays links to nodes created on this date") . '</p>';
break;
}
}
/**
* Implements hook_block_info().
*/
/** * Declaring the block */
function MyCustomBlock_block_info() {
$blocks['MyCustomBlock'] = array(
// The name that will appear in the block list.
'info' => t('MyCustomBlock'),
// Default setting.
'cache' => DRUPAL_CACHE_PER_ROLE,
);
return $blocks;
}
/** * Preparing for a module configuration form * Implements
hook_menu(). */
function MyCustomBlock_menu() {
$items = array();
$items['admin/config/content/MyCustomBlock'] = array(
'title' => 'MyCustomBlock',
'description' => 'Configuration for MyCustomBlock module',
'page callback' => 'drupal_get_form',
'page arguments' => array('MyCustomBlock_form'),
'access arguments' => array('access administration pages'),
'type' => MENU_NORMAL_ITEM,
);
return $items;
}
/* * Adding JavaScript from within a module */
function MyCustomBlock_add_js($data = NULL, $options = NULL) {
$javascript = &drupal_static(__FUNCTION__, array());
$jquery_added = &drupal_static(__FUNCTION__ . ':jquery_added', FALSE);
}
I can see my block module in the /admin/modules
section and I can enable my custom block module. But, I am not sure how to add that script into my module.
Thanks for the help!