Drupal学习

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;
  }

标签: 

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 7 对数组内容分页

This example shows how to generate a render array from an array of data that includes a pager. This example will theme the content as an item_list, but the content section could be parsed and rendered as a table or by any other means, depending on the content of the $rows array.

The trick to using theme_pager(), as I discovered, is that (under normal circumstances and typical usage) it gets all of its information from pager_default_initialize(). The output selection is handled by the PHP array_slice() function.

标签: 

给CKEditor换个皮肤

标签: 

把 CSV 数据作为文件下载

If you ever need to save a set of columnar data as a csv file on the server, doing so using fopen() and fputcsv() is pretty simple. What you may not know, and what I didn't know until recently, was how to take that same data and return it as a downloadable csv file (not saved on the server). Turns out, accomplishing this task in Drupal is just as easy as saving a file but with one minor tweak.

Saving To a File

As a recap for some, and a primer for others, here's how we'd take some data and save it as a file on the server:

标签: 

Drupal 获取当前用户积分

userpoints_get_current_points($uid = NULL, $tid = NULL)

标签: 

Drupal 获取文章浏览统计


function statistics_get($nid) {

if ($nid > 0) {
// Retrieve an array with both totalcount and daycount.
return db_query('SELECT totalcount, daycount, timestamp FROM {node_counter}
WHERE nid = :nid', array(':nid' => $nid), array('target' => 'slave'))->fetchAssoc();
}
}

参数 $nid: 文章id

返回值

数组,包含:totalcount(浏览总数量)daycount(今日浏览数)timestamp(最后一次浏览时间戳)

标签: 

页面