Đây là 1 ví dụ về hook_user_view_alter được sử dụng trong module userpoints_donation
function userpoints_donation_user_view_alter(&$build) {
global $user;
if (user_access('give points to another user') && $build['#account']->uid != $user->uid) {
$build['userpoints']['actions']['#links']['userpoints_donation'] = array(
'href' => 'userpoints_donation/' . $build['#account']->name,
'title' => t('Donate !points to this user', userpoints_translation()),
'query' => drupal_get_destination(),
);
}
}
?>
Comments
http://api.drupal.org/api/dru
http://api.drupal.org/api/drupal/modules--user--user.api.php/function/ho...
Vào trrang API của drupal mà tra đi bạn :)
Dùng Google Translate
Ờ, vào đó là chắc ăn nhất, đỡ phải đoán non đoán già :D.
EN chưa thạo thì dùng từ điển + Google translate để dịch, dần dần rồi sẽ quen.
http://codeandmore.com/
Bạn tham khảo trong module userpoints_donation
Đây là 1 ví dụ về hook_user_view_alter được sử dụng trong module userpoints_donation
function userpoints_donation_user_view_alter(&$build) {
global $user;
if (user_access('give points to another user') && $build['#account']->uid != $user->uid) {
$build['userpoints']['actions']['#links']['userpoints_donation'] = array(
'href' => 'userpoints_donation/' . $build['#account']->name,
'title' => t('Donate !points to this user', userpoints_translation()),
'query' => drupal_get_destination(),
);
}
}
?>
Hook này để xử lý khi view
Hook này để xử lý khi view tài khoản của user, mình có thể thêm các field hoặc 1 luồng xử lý nào đó chẳng hạn
siêu thị điện máy , máy hút bụi , lò vi sóng
Không đọc được tiếng anh ?
Êk ! lập trình thì phải thành thạo anh ngữ, hoặc đủ dùng chứ, vào API của nó tra cái là ra !
My blog: Jamviet.com, Hỏi đáp trực tuyến, váy dài