Goals

  1. Learn at least one new language every year.
  2. Read a technical book each quarter.
  3. Read nontechnical book, too.
  4. Take classes.
  5. Participate in local user groups.
  6. Experiment with different environments.
  7. Stay current.
  8. Get wired.

db_or

$or = db_or();
$or->condition();
$or->condition();
$query->condition($or);

标签: 

Drupal 邮箱登陆

function HOOK_user_login_validate($form, &$form_state) {
  if (isset($form_state['values']['name']) && $form_state['values']['name']) {
    if ($name = db_query("SELECT name FROM {users} WHERE LOWER(mail) = LOWER(:name)", array(
      ':name' => $form_state['values']['name'],
    ))->fetchField()) {
      form_set_value($form['name'], $name, $form_state);
    }
  }
}

来自logintoboggan模块

Nginx 私有文件重定向

location ^~ /system/files/ {
  rewrite ^ /index.php;
}

标签: 

Nginx 配置 Boost

set $boost "";
set $boost_query "_";
 
if ( $request_method = GET ) {
    set $boost G;
  }
 
  if ($http_cookie !~ "DRUPAL_UID") {
    set $boost "${boost}D";
  }
 
  if ($query_string = "") {
    set $boost "${boost}Q";
  }
 
  if ( -f $document_root/cache/normal/$host$request_uri$boost_query.html ) {
    set $boost "${boost}F";
  }
 
  if ($boost = GDQF){
    rewrite ^.*$ /cache/normal/$host/$request_uri$boost_query.html break;
  }
 
  if (!-e $request_filename) {
      rewrite ^/(.*)$ /index.php?q=$1 last;
      break;
  }

标签: 

nodes programmatically in drupal 7

js通过参数名获取url查询中参数的值

function getParameterByName(name) {
    name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
    var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
        results = regex.exec(location.search);
    return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}

标签: 

Drupal 获取字段label

$info = field_info_instance('node','field_name','content_type_name');
print $info['label'];

标签: 

Page templates depending on node type drupal7

<?php
function themename_preprocess_page(&$variables) {
  if (!empty($variables['node'])) {
    $variables['theme_hook_suggestions'][] = 'page__node__' . $variables['node']->type;
  }
}
?>

Drupal 获取字段label

$info = field_info_instance('node','field_name','content_type_name');
 print $info['label'];

页面