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
$files = array('readme.txt', 'test.html', 'image.gif'); | |
$zipname = 'file.zip'; | |
$zip = new ZipArchive; | |
$zip->open($zipname, ZipArchive::CREATE); | |
foreach ($files as $file) { | |
$zip->addFile($file); | |
} | |
$zip->close(); |
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
//used for views-view-fields.tpl.php | |
// Prepare views row, field by field | |
foreach ($fields as $id => $field): | |
switch ($id) { | |
case 'title': | |
$title = $field->content; | |
break; | |
case 'field_id': | |
$field_name = $field->content; | |
break; |
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
$theme_path = drupal_get_path('theme',$GLOBALS['theme']); |
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
//returns an array of url query parameters | |
$query = drupal_get_query_parameters(); | |
dpm($query); |
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
//drupal link function | |
<?php | |
$link = l(t('Link Text'), 'URL', array( | |
'query' => array( | |
drupal_get_destination(), | |
'key' => 'value', | |
), | |
'attributes' => array( | |
'title' => t('Link Title'), | |
'id' => 'id-string', |
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
//checks if user has role | |
global $user; | |
$user_check = array_intersect(array('moderator', 'administrator'), array_values($user->roles)); | |
if (empty($check) ? FALSE : TRUE) { | |
return $output; | |
} else { | |
// $user is not admin | |
} |
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
$output = ''; | |
//load blocks then render the returned objects | |
$myblock = block_load('module', 'block_delta'); | |
$block = _block_render_blocks(array($myblock))); | |
$block = _block_get_renderable_array($block); | |
$output = drupal_render($block); | |
print $output; |
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
Output field as is in drupal ui: | |
$output = field_view_field('node', $node, 'field_name'); | |
Just want a single value, and none of the field markup: | |
$node = node_load($nid); | |
$field = field_get_items('node', $node, 'field_name'); | |
$output = field_view_value('node', $node, 'field_name', $field[$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 | |
/** | |
* @file | |
* Drupal site-specific configuration file. | |
* | |
* IMPORTANT NOTE: | |
* This file may have been set to read-only by the Drupal installation program. | |
* If you make changes to this file, be sure to protect it again after making | |
* your modifications. Failure to remove write permissions to this file is a |
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 | |
// Reference http://www.computerminds.co.uk/articles/rendering-drupal-7-fields-right-way | |
//dpm($node); | |
// adding prefix and suffic html wraps | |
if (isset($content['field_urgent_check'])) { | |
$content['field_urgent_check']['#title'] = 'Urgent Job?'; | |
$content['field_urgent_check']['#prefix'] = '<div class="node-data">'; | |
$content['field_urgent_check']['#suffix'] = '</div>'; | |
print render($content['field_urgent_check']); | |
} |
OlderNewer