override module

CP Module

<?php
/**
* Implements hook_block().
*/
function cp_block($op = 'list', $delta = 0, $edit = array()) {
  if (
$op == 'list') {
   
$blocks = array();

   
$blocks['theme_switcher'] = array(
     
'info' => t('Theme Switcher'),
    );

    return
$blocks;
  }
  elseif (
$op == 'view') {
    switch(
$delta) {
      case
'theme_switcher':

      
// Capture the cp variable
      
$cp_theme = $_REQUEST['cp'];

      
// If it is already set, remove it from
       // the destination link - else, add it
      
if ($cp_theme == 'true') {
        
$cp = '';
       }
       else {
        
$cp = 'true';
       }

      
// Allow drupal to render the link
      
$link = l(t('Switch Theme'), $_REQUEST['q'], array('query' => array('cp' => $cp)));

        return array(
         
'subject' => t('Theme Switcher'),
         
'content' => theme('switcher_block', $link),
        );
        break;
    }
  }
}

/**
* Implements hook_theme().
*/
function cp_theme($existing, $type, $theme, $path) {
  return array(
   
'switcher_block' => array(
     
'template' => 'switcher_block',
     
'arguments' => array(
       
'link' => NULL,  
      ),
    ),
  );
}

/**
* Default implementation of theme_switcher_block().
*/
function theme_switcher_block() {
  return
'My themed block content';
}
?>

Override Module

<?php
/**
* Implements hook_form_alter().
*/
function override_form_alter(&$form, $form_state, $form_id) {
  switch (
$form_id) {
    case
'event_node_form':

     
// Require the body
     
$form['body_field']['body']['#required'] = TRUE;

     
// Add in our own submit handler
     
$form['#submit'][] = 'override_node_submit';
      break;
  }
}

/**
* Custom submit handler
*/
function override_node_submit($form, &$form_state) {
 
dpm('Submit handler function');
}

function
override_form_event_node_form_alter(&$form, $form_state) {
}

/**
* Implements hook_nodeapi().
*/
function override_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {

  switch (
$op) {
    case
'load':
      foreach (
$node as $key => $value) {
        if (
preg_match('/^field_english_(.*)$/', $key, $matches)) {
         
$node->translated[$matches[1]] = $value[0];
        }
      }
      break;
  }
     
drupal_set_title($node->translated['title']['value']);
}

/**
* Implements hook_menu().
*/
function override_menu() {
 
$items = array();

 
$items['override'] = array(
   
'title' => 'My override page',
   
'page callback' => 'override_pageview',
   
'access arguments' => array('access override page'),
  );
 
$items['override/settings'] = array(
   
'title' => 'My override page',
   
'page callback' => 'override_pageview',
   
'access arguments' => array('access override page'),
   
'type' => MENU_DEFAULT_LOCAL_TASK,
  );
 
$items['override/options'] = array(
   
'title' => 'My override page',
   
'page callback' => 'override_pageview_options',
   
'access arguments' => array('access override page'),
   
'type' => MENU_LOCAL_TASK,
  );

  return
$items;
}

/**
* Implements hook_perm().
*/
function override_perm() {
  return array(
   
'access override page',
  );
}

function
override_pageview_options() {
  return
'my options page';
}

function
override_pageview() {
  return
'my page';
}
?>

Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <span> <a>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.

More information about formatting options

Type the characters you see in this picture. (verify using audio)
Type the characters you see in the picture above; if you can't read them, submit the form and a new image will be generated. Not case sensitive.
My name is Kevin. I am a software engineer and bike geek living in Salem, Mass. I use Vim even when I don't need to. When I'm not on the computer, I'm usually hanging with my wife, Melissa and baby Benjamin or working on my pet project BIKENE.WS.