This file contains hidden or 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
When dealing with arrays in PHP, checking for an index like `if ($a['foo'])` throws a PHP warning. | |
There are two ways to avoid these warnings: one is using isset(), which checks the existance of an array index. The second one is empty(), which not only checks for the existence of the array index, but also that the value that contains is not empty (not NULL, 0, '' or FALSE). | |
Here are some console examples: | |
```bash | |
juampy@juampybox $ php -a | |
php > $a = array('foo' => 'asdfasd'); | |
php > |
This file contains hidden or 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 | |
* Default theme implementation to display the basic html structure of a single | |
* Drupal page. | |
* | |
* Variables: | |
* - $css: An array of CSS files for the current page. | |
* - $language: (object) The language the site is being displayed in. |
This file contains hidden or 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 | |
/* | |
* Check node ID to remove duplicate result. | |
* | |
*/ | |
function MODULENAME_views_pre_render(&$view) { | |
//dpm($view->name); | |
if ($view->name == 'taxonomy_term') { | |
$nids = array(); |
This file contains hidden or 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 | |
// Get path of Drupal install. | |
$drupal_path = $_SERVER['DOCUMENT_ROOT']; | |
// Defines our path to the Drupal install | |
define('DRUPAL_ROOT', $drupal_path); | |
// We need to load the bootstrap.inc file so we can have access to the drupal_bootsrap() function | |
require_once DRUPAL_ROOT . '/includes/bootstrap.inc'; |
This file contains hidden or 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_update_projects_alter(&$projects) { | |
// Hide a site-specific module from the list. | |
unset($projects['custom']); | |
} |
This file contains hidden or 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 | |
/* | |
* | |
* @filename: aliases.drushrc.php | |
* Drop this php file into your home directory .drush folder | |
* e.g on my Windows 7 PC, directory looks like this | |
* c:\Users\Userna\.drush | |
* and on Linux it should be /home/yourusername/.drush | |
* |
This file contains hidden or 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 commerce_subscriptions_update_projects_alter(&$projects) { | |
// Hide a site-specific module from the list. | |
unset($projects['commerce_subscriptions']); | |
} |
This file contains hidden or 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_form_alter | |
* | |
*/ | |
function lms_form_alter(&$form, $form_state, $form_id) { | |
if ($form_id == 'user_register_form') { | |
drupal_set_title(t('Create new account')); | |
} |
This file contains hidden or 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_form_FORMID_alter(). | |
*/ | |
function arma_form_commerce_cart_add_to_cart_form_alter(&$form, &$form_state) { | |
$cart_product_ids = arma_get_products_in_cart(); | |
$purchased_product_ids = arma_get_users_purchased_products(); | |
$line_item = $form_state['line_item']; | |
$product = commerce_product_load($line_item->commerce_product[LANGUAGE_NONE][0]['product_id']); |
This file contains hidden or 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_form_alter | |
* | |
*/ | |
function arma_form_alter(&$form, $form_state, $form_id) { | |
if ($form_id === 'commerce_cart_add_to_cart_form_2' || $form_id === 'commerce_cart_add_to_cart_form_1') { | |
$form['submit']['#attributes']['title'] = $form['submit']['#attributes']['value'] = t('Buy Corporate Membership'); | |
} |