Created
April 22, 2016 22:10
-
-
Save reubenmoes/5412196be668481d908f392f2ca84ebf to your computer and use it in GitHub Desktop.
super rough block + js + drupal.settings
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
/** | |
* Implements hook_block_info(). | |
* | |
* This hook declares what blocks are provided by the module. | |
*/ | |
function block_example_block_info() { | |
// This sample shows how to provide default settings. In this case we'll | |
// enable the block in the first sidebar and make it visible only on | |
// 'node/*' pages. See the hook_block_info() documentation for these. | |
$blocks['example_empty'] = array( | |
// info: The name of the block. | |
'info' => t('Example: configurable text string'), | |
// Block caching options (per role, per user, etc.) | |
// DRUPAL_CACHE_PER_ROLE is the default. | |
'cache' => DRUPAL_CACHE_PER_ROLE, | |
); | |
return $blocks; | |
} | |
/** | |
* Implements hook_block_view(). | |
* | |
* This hook generates the contents of the blocks themselves. | |
*/ | |
function block_example_block_view($delta = '') { | |
// The $delta parameter tells us which block is being requested. | |
switch ($delta) { | |
case 'example_empty': | |
$block['subject'] = t('Title of second block (example_empty)'); | |
$block['content'] = block_example_contents($delta); | |
$block['content'] = array( | |
'#markup' => '<>', | |
'#attached' => array( | |
'js' => array( | |
'data' => get_map_data(), | |
'type' => 'settings' | |
) | |
) | |
); | |
break; | |
} | |
return $block; | |
} | |
function get_map_data(){ | |
//something like this : https://bitbucket.org/domain7/drupal-humanitas/src/df84fc24c3a9096092aa031b31ef774ad2dc61bd/sites/all/modules/humanitas_api/humanitas_api.module?at=master&fileviewer=file-view-default | |
$data = array(); | |
$nodes = node_load_multiple(array(), array('type' => 'my_typ')); | |
foreach($nodes as $node){ | |
$data[] = node_map_info($node); | |
} | |
return $data; | |
} | |
function node_map_info($node){ | |
$node_data = array(); | |
$node_data['lat'] = ....; | |
$node_data['lon'] = ....; | |
$node_data['title'] = ....; | |
$node_data['teaser'] = ....; | |
return $node_data; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment