Sample Drupal PHP codes

Control of Block Display

<?php
  global $user;

  $match = TRUE;

  $path = drupal_get_path_alias($_GET['q']);

  if (preg_match('@^content/webform/.+/buddha/2010.*@', $path) ||
      preg_match('@.*tzu-chi-academy.*@', $path) ||
      preg_match('@^gallery/119/13859/13864$@', $path) ||
      preg_match('@^gallery/119/13859/13864/.+$@', $path) ||
      0) {
      $match = FALSE;
  }

  if (in_array('anonymous user',$user->roles)) {
    $match = TRUE;
  }

  return $match;
?>

Drush PHP scripts

drush php-script --script-path=/path/to/scripts scriptname # .php not needed

<< quoted from http://groups.drupal.org/node/94304>>

mySQL SELECT codes

table: content_type_dictionary_term
field: nid
field: vid
field: field_dict_duplicate_check_value

table: dictionary_item
field: iid
field: name

table: node
field: nid
field: vid

 
SELECT node.nid AS nid,
   node.title AS node_title,
   node.language AS node_language,
   node_data_field_dict_duplicate_check.field_dict_duplicate_check_value AS node_data_field_dict_duplicate_check_field_dict_duplicate_check_value,
   node.type AS node_type,
   node.vid AS node_vid
 FROM node node 
 LEFT JOIN content_type_dictionary_term node_data_field_dict_duplicate_check ON node.vid = node_data_field_dict_duplicate_check.vid
 WHERE (node.type in ('dictionary_term')) AND (node.nid >= 35380)
   ORDER BY node_title ASC

PHP Views filter

http://drupal.org/node/1407522

http://drupal.org/node/1407538

http://drupal.org/node/1407528

 

X
You may login with either your assigned username or your e-mail address.
The password field is case sensitive.
Loading