Display for logged in users

ผมใช้เวลานานกว่าจะหาทางทำให้ drupal (4.7.x) แสดง block เฉพาะ user ที่ login แล้วได้

วิธีการง่ายๆ (แต่หา document ยาก) แค่ ใส่คำสั่งต่อไปนี้ในส่วนของ Page specific visibility settings ของ block นั้นๆ (ให้เลือก Show if the following PHP code returns TRUE (PHP-mode, experts only) ก่อนด้วยครับ)

< ?php
global $user;
return (bool) $user->uid;
?>

URL ที่เกี่ยวข้อง:

http://drupal.org/node/60317

http://drupal.org/node/64854

Popularity: 51% [?]

Display different page content to anonymous and authenticated users

< ?php
/**
* The following simple snippet
* displays different information to anonymous/logged in users within a page.
*
* This works with drupal 4.5 and drupal 4.6
*/
global $user;
if (
$user->uid) {
return
“This message is only visible for logged-in users.”;
}
if (!
$user->uid) {
return
“This message is only visible for not-logged-in users.”;
}
?>

Popularity: 59% [?]

Show external page in the main screen of Drual

วิธีการใส่ external page ใน drupal ครับ แต่รูปภาพอาจไม่มาด้วย :)

< ?php
ob_start
();
include_once
"http://www.WebSiteToInclude.com/";
$output = ob_get_contents();
ob_end_clean();
return
$output;
?>

Popularity: 54% [?]