This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* Implements hook_node_insert() | |
* | |
* Sends an email when a node is added | |
*/ | |
function mail_node_insert($node) { | |
if ($node->type == "blog") { | |
mail('[email protected]', 'Blog Updated', | |
'Link: http://example.com/node/' . $node->nid); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* Implements hook_node_view() | |
* | |
* Adds a note to each article node | |
*/ | |
function mymodule_node_view($node, $view_mode) { | |
if ($node->type == 'article') { | |
$node->content['mymodule_note'] = array(); | |
$node->content['mymodule_note']['#markup'] = |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function mymodule_node_list() { | |
$items = array( | |
array('Suzanne'), | |
array('Alex'), | |
array('Tavish'), | |
array('Thomas'), | |
); | |
//asks Drupal to render this as a list | |
return array( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* Implements hook_block_view(). | |
* | |
* Displays an ad block. | |
*/ | |
function mymodule_block_view($delta = '') { | |
$block = array(); | |
switch ($delta) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* Implements hook_block_info() | |
* | |
* Adds a custom block | |
*/ | |
function mymodule_block_info() { | |
$blocks['ad'] = array( | |
'info' => t('Advertisement'), | |
// DRUPAL_CACHE_PER_ROLE assumed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Implementation of hook_init(). | |
* | |
* Displays a diagnostic message to the user. | |
*/ | |
function ew_recent_nodes_init() { | |
$message = t("The Recent Nodes module is enabled!"); | |
drupal_set_message($message); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @file | |
* Implements a Solr proxy. | |
* | |
* Currently requires json_decode which is bundled with PHP >= 5.2.0. | |
* | |
* You must download the SolrPhpClient and store it in the same directory as this file. | |
* |