Drupal是一个基于PHP语言的开源内容管理系统(Content Management System),所以文本数据以及图形、音频等其它文件类型的文本指针都以数据库的形式储存,用户可以通过浏览器对Drupal发送请求,而Drupal 刚动态的从数据库中读取数据生成静态网页发送给用户。通过Drupal系统,我们可以在不修改任何一句程序语言的前提下实现很强大的功能,比如多用户博客(Blog)系统,论坛(Fourm)系统,联合协作文档编写系统(Collaborative Book),多用户访问权限级别分配系统等,这些在你成功安装Drupal系统之后就能很轻易的实现。而如果再为Drupal核心系统安装Module以扩展其功能,那么,Drupal几乎可以完成任何你想让它完成的事情,当然这也得Drupal的使用有一定的经验来选择正确的Module或者有良好的程序编写功底来编写自己需要的功能的程序模块,这些都是后话了。本文对Drupal的核心功能(即安装Drupal之后不进任何Module扩展下的功能)进行一个详细的功能及使用方法的介绍。
Drupal核心功能介绍与入门使用教程
黄超, 2009/12/20 20:27:27, § 0
在Drupal中如何使用昵称代替用户名(账号)
黄超, 2009/12/20 18:57:34, § 0
原文名为:Create an alias instead of user username
This code was taken from the forum which I believe was also taken from somewhere else. I have made some fixes that allow it to work with comments and forums. Please claim responsibility if the original code was yours.
This snippet allows you to display user friendly alias names on posts and comments etc. This comes in useful if your using the Webserver_auth module and don’t want to see webserver usernames on your site. It allows the users to set an alias in their profile which is then displayed on the site. If the profile field isn’t set then it will use the users username.
You will need to enable the profile module and add a single line text field to your users profiles. You can call it anything you want but you will need to alter the code as appropriate. For this example I called my field ‘profile_fullname’.
In your template.php file you will need
<?php
function phptemplate_username($object) {
if ($object->in_preview) {
return theme_username($object);
}
return _phptemplate_callback('username', array('object' => $object));
}
?>
Create a file called ‘username.tpl.php’ with these contents
<?php
if ($object->uid && $object->name) {
// If the user has a full name defined, use that
$account = user_load(array(uid => $object->uid));
$profilename = $object->name;
if (!empty($account->profile_fullname)) {
$profilename = $account->profile_fullname;
}
// Shorten the name when it is too long or it will break many tables.
if (drupal_strlen($profilename) > 20) {
$name = drupal_substr($profilename, 0, 15) .'...';
}
else {
$name = $profilename;
}
if (user_access('access user profiles')) {
$output = l($name, 'user/'. $object->uid, array('title' => t('View user profile.')));
}
else {
$output = check_plain($name);
}
}
else if ($object->name) {
// Sometimes modules display content composed by people who are
// not registered members of the site (e.g. mailing list or news
// aggregator modules). This clause enables modules to display
// the true author of the content.
if ($object->homepage) {
$output = l($object->name, $object->homepage, array('title' => t('View link')));
}
else {
$output = check_plain($object->name);
}
$output .= ' ('. t('not verified') .')';
}
else {
$output = variable_get('anonymous', 'Anonymous');
}
print $output;
?>
You can change a page title with the drupal_set_title function.
A good place for it in this instance would be in a customized version of the theme_user_profile function, placed in your template.php file:
<?php
/**
* An implementation of theme_user_profile
*/
function phptemplate_user_profile($account, $fields) {
// change the profile page's title to the specified profile field
// but only if we are actualy viewing a profile page and if the specified profile field has a value
if ((arg(0) == 'user') && $account->profile_fullname) {
drupal_set_title($account->profile_fullname);
}
$output = '<div class="profile">';
$output .= theme('user_picture', $account);
foreach ($fields as $category => $items) {
if (strlen($category) > 0) {
$output .= '<h2 class="title">'. $category .'</h2>';
}
$output .= '<dl>';
foreach ($items as $item) {
if (isset($item['title'])) {
$output .= '<dt class="'. $item['class'] .'">'. $item['title'] .'</dt>';
}
$output .= '<dd class="'. $item['class'] .'">'. $item['value'] .'</dd>';
}
$output .= '</dl>';
}
$output .= '</div>';
return $output;
}
?>
Next, to change the page title so that the user name is shown on the profile page, instead of the alias:
You can change a page title with the drupal_set_title function. A good place for it in this instance would be in a customized version of the theme_user_profile function, placed in your template.php file:
<?php
/**
* An implementation of theme_user_profile
*/
function phptemplate_user_profile($account, $fields) {
// change the profile page's title to the specified profile field
// but only if we are actualy viewing a profile page and if the specified profile field has a value
if ((arg(0) == 'user') && $account->profile_fullname) {
drupal_set_title($account->profile_fullname);
}
$output = '<div class="profile">';
$output .= theme('user_picture', $account);
foreach ($fields as $category => $items) {
if (strlen($category) > 0) {
$output .= '<h2 class="title">'. $category .'</h2>';
}
$output .= '<dl>';
foreach ($items as $item) {
if (isset($item['title'])) {
$output .= '<dt class="'. $item['class'] .'">'. $item['title'] .'</dt>';
}
$output .= '<dd class="'. $item['class'] .'">'. $item['value'] .'</dd>';
}
$output .= '</dl>';
}
$output .= '</div>';
return $output;
}
?>
一代大师萨缪尔森去世
黄超, 2009/12/15 22:09:54, § 0
今天看到新闻,说美国经济学泰斗保罗•A•萨缪尔森十三日在其位于美国马萨诸塞州的家中逝世,享年九十四岁。
记得在大学上西方经济学时,还在图书馆借阅过他的《经济学》,感觉其遣词说理、图文举例皆深入浅出,比我们用的教材要好得多。
萨缪尔森在经济学领域中可以说是无处不在,被称为经济学界的最后一个通才。美联社当天在报道中总结萨缪尔森一生主要成就时说:他将数学分析方法引入经济学,帮助经济困境中上台的肯尼迪政府制定了著名的“肯尼迪减税方案”,并且写出了一部被数百万大学生奉为经典的教科书。
祝大师灵魂得升天堂!
人这一辈子
黄超, 2009/12/12 22:03:35, § 0
……
但聪慧如柔娘,理解他的意思并不费力,痴痴望着他的脸,幽幽道:“大人曾经对奴婢说,人这一辈子,最重要的是要搞清楚两个问题……”
“要的是什么,和正在做什么。”沈默点点头,轻声道:“只要在这两个问题上一直保持清醒,这一生就不会太令自己失望。”
……
语出三戒大师之《官居一品》