function {module_name}_views_default_views() {
{...view code...}
$views[$view->name] = $view; // include this line after each view's code
return $views;
}
Tag Archive for drupal
Views default function
Views API module declaration
function {module_name}_views_api() {
return array('api' => 2.0);
}
Image Cache Preset manuell im Template verwenden
theme('imagecache', Imagecache-Preset, filepath,title,alt);
hook_form_alter for views exposed filter form
/**
* Implementation of hook_form_FORM_ID_alter() for 'views exposed form'
* Change the first option label '<All>' to 'Filter by Identifier Name' for exposed filters
* The filter identifier needs set up with underscores for multiple word filter names
* e.g. 'document_type' becomes 'Document Type'
*/
function mymodule_form_views_exposed_form_alter (&$form, $form_state) {
foreach($form as $key => &$value) {
if(isset($value['#options']['All'])) {
$label = ucwords(strtolower(str_replace('_', ' ', $key)));
$value['#options']['All'] = t('Filter by !label', array('!label' => $label));
}
}
}
Use drush sql dump to dump the database to the file system.
drush sql dump > /path/to/BACKUPS/site_name-$(date +%Y-%m-%d-%H.%M.%S).sql
Use drush sql dump to dump the database to the file system.
drush sql dump > /path/to/BACKUPS/site_name-$(date +%Y-%m-%d-%H.%M.%S).sql
Use drush to dump a space separated list of enabled modules to a text file.
drush statusmodules --pipe | cat > mods_enabled.txt
Drupal hook_block 6.x
<?php
function hook_block($op = 'list', $delta = 0, $edit = array()) {
switch ($op) {
case 'list':
$blocks[0]['info'] = t('Block 1');
$blocks[1]['info'] = t('Block 2');
return $blocks;
case 'configure':
if ($delta == 0 && user_access('administer module')) {
$form['module_block_1'] = array();
}
if ($delta == 1 && user_access('administer module')) {
$form['module_block_2'] = array();
}
return $form;
case 'save':
if ($delta == 0) {
variable_set('module_block_setting_1', $edit['module_block_1']);
}
if ($delta == 1) {
variable_set('module_block_setting_2', $edit['module_block_2']);
}
break;
case 'view':
if ($delta == 0) {
$block['subject'] = t('Block 1 title');
$block['content'] = t('Block 1 content');
}
if ($delta == 1) {
$block['subject'] = t('Block 2 title');
$block['content'] = t('Block 2 content');
}
return $block;
}
}
drupal json
//output json drupal_json(array( 'mrates' => $current_m_rates, 'frates' => $current_f_rates, ) );