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 THEME_preprocess_page() { | |
global $user; | |
$user = user_load($user->uid); // Make sure the user object is fully loaded | |
$full_names = field_get_items('user', $user, 'field_full_name'); | |
if ($full_names) { | |
$vars['full_name'] = check_plain($full_names[0]['value']); | |
} | |
} |
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 THEME_preprocess_page() { | |
global $user; | |
$user = user_load($user->uid); // Make sure the user object is fully loaded | |
$wrapper = entity_metadata_wrapper('user', $user); | |
$vars['full_name'] = $wrapper->field_full_name->value(array('sanitize' => TRUE)); | |
} |
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 custom_node_validate($node, $form, $form_state){ | |
// special character list, Add more special character if you want. | |
$special_character_list = '\'^£$%&*()}{@#~?><>,|=_+¬\-\[\]'; | |
if(preg_match('/[' . $special_character_list . ']/', $node->title) !== 0){ | |
form_set_error('title', t("Special characters !special_character_list are not allowed in title.", array('!special_character_list' => $special_character_list))); | |
} | |
} |
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 | |
//Open template.php in your theme folder and add the following code. Replace [THEME NAME] with the name of your theme. Replace the value of $module and $delta with the actual string values. | |
//Hint: To locate these values go to admin/structure/block and click on the "configure" link next to the block you want to print. The strings will be shown in the URL as such: admin/structure/block/manage/[module]/[delta]/configure. | |
/** | |
* Implements preprocess_block(). | |
*/ | |
function mytheme_preprocess_block(&$vars) { | |
// Preprocess the Contact form block. | |
$module = 'block'; |
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 | |
//1. Open template.php in your theme folder and add the following code. Replace [THEME NAME] with the name of your theme. Replace the value of $nid with the actual ID of your node. | |
/** | |
* Implements preprocess_node(). | |
*/ | |
function mytheme_preprocess_node(&$vars) { | |
// Print contact form on contact page. | |
$nid = 7; | |
if ($vars['node']->nid == $nid && module_exists('contact')) { | |
module_load_include('inc', 'contact', 'contact.pages'); |
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
# set the "require_auth" var if Host ends with "example2.com" | |
SetEnvIfNoCase Host example2\.com$ require_auth=true | |
# Auth stuff | |
AuthUserFile /var/www/htpasswd | |
AuthName "Password Protected" | |
AuthType Basic | |
# Setup a deny/allow | |
Order Deny,Allow |
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 | |
$aliases["loc"] = array ( | |
'root' => '/absolute/path/to/local/mywebsite', | |
'uri' => 'http://default', | |
'path-aliases' => | |
array ( | |
// Change it to your drush installation path. | |
'%drush' => '/Applications/Dev Desktop/drush/vendor/drush/drush', | |
// Website folder relative path. | |
'%site' => 'sites/default/', |
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
#!/usr/bin/php | |
<?php | |
print_r(arguments($argv)); | |
function arguments($args) { | |
$ret = array( | |
'exec' => '', | |
'options' => array(), | |
'flags' => array(), | |
'arguments' => 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 | |
function recurse_copy($src, $dst) { | |
$dir = opendir($src); | |
$result = ($dir === false ? false : true); | |
if ($result !== false) { | |
$result = @mkdir($dst); | |
if ($result === true) { |
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 | |
// In custom module | |
function mymodule_preprocess_html(&$variables) { | |
// Add conditional stylesheets for admin pages on admin theme. | |
if (arg(0)=="admin") { | |
// reference your current admin theme | |
$theme_path = drupal_get_path('theme', 'commerce_kickstart_admin'); | |
// reference your own stylesheet | |
drupal_add_css(drupal_get_path('module', 'mymodule') . '/css/mymodule.css', array('weight' => CSS_THEME)); | |
} |