Sunday, April 24, 2011

Showing a block conditionally based on the node type of the page

I recently created a block view that I wanted to include only on pages of a certain node type. I decided to create a PHP function that returns true or false based based on the page URL and then call the function via the "Page specific visibility settings", on the block edit screen.

This function returns true or false based on the what type of node the page URL is. I added this function to my template.php file, but you could add it to a module if desired.

<?php
function _MYTHEME_MYBLOCK_visibility() {
// look up the system path from the page URL
$path = drupal_lookup_path('source', $_REQUEST['q']);

// check if the page is a node
if (substr($path,0,5)=='node/') {
// load node
$node = node_load(substr($path,5));

// check if node exists
if (!$node) return false;

// check node type
if ($node->type == 'MYNODETYPE') return true;

} else {
return false;
}
}
?>
 

Then I added a PHP snippet in the "Page specific visibility settings" on the block edit screen:
<?php
if (function_exists('_MYTHEME_MYBLOCK_visibility')) return _MYTHEME_MYBLOCK_visibility();
return false;
?>

Now, the block only shows on pages of "MYNODETYPE".

from: http://thedrupalblog.com/category/tags/page-specific-visibility-settings

Showing a block conditionally based on the node type of the page

I recently created a block view that I wanted to include only on pages of a certain node type. I decided to create a PHP function that returns true or false based based on the page URL and then call the function via the "Page specific visibility settings", on the block edit screen.

This function returns true or false based on the what type of node the page URL is. I added this function to my template.php file, but you could add it to a module if desired.

<?php
function _MYTHEME_MYBLOCK_visibility() {
// look up the system path from the page URL
$path = drupal_lookup_path('source', $_REQUEST['q']);

// check if the page is a node
if (substr($path,0,5)=='node/') {
// load node
$node = node_load(substr($path,5));

// check if node exists
if (!$node) return false;

// check node type
if ($node->type == 'MYNODETYPE') return true;

} else {
return false;
}
}
?>
 

Then I added a PHP snippet in the "Page specific visibility settings" on the block edit screen:
<?php
if (function_exists('_MYTHEME_MYBLOCK_visibility')) return _MYTHEME_MYBLOCK_visibility();
return false;
?>

Now, the block only shows on pages of "MYNODETYPE".

from: http://thedrupalblog.com/category/tags/page-specific-visibility-settings

Thursday, April 7, 2011

copy tren net

Trăng hôm nay cao quá ,
Anh muốn hôn vào má .
Trăng hôm nay cao tít ,
Anh muốn hôn vào .....
Trăng hôm nay mới nhú,
Anh muốn hôn vào .....


Bước chân dô quán đèn mờ.
Ngồi gần con gái không sờ là ngu!!
Thà rằng cắt tóc đi tu.
Ngồi gần con gái ..... ngu sao không sờ!!

Con người càng lúc càng đông.
Thạch Sanh thì ít , Lý thông thì nhiều .

copy tren net

Trăng hôm nay cao quá ,
Anh muốn hôn vào má .
Trăng hôm nay cao tít ,
Anh muốn hôn vào .....
Trăng hôm nay mới nhú,
Anh muốn hôn vào .....


Bước chân dô quán đèn mờ.
Ngồi gần con gái không sờ là ngu!!
Thà rằng cắt tóc đi tu.
Ngồi gần con gái ..... ngu sao không sờ!!

Con người càng lúc càng đông.
Thạch Sanh thì ít , Lý thông thì nhiều .

Wednesday, April 6, 2011

Chuyện kể chủ tịch Triết sang Mỹ nói chuyện với TT Obama về an sinh xã hội

Chuyện kể chủ tịch Triết sang Mỹ nói chuyện với TT Obama về an sinh xã hội. Triết hỏi Obama:

T: Ở nước Mỹ lương tối thiểu là bao nhiêu?
O: 1300 đô la
T: Thế trung bình một người Mỹ mỗi tháng xài hết bao nhiêu?
O: Khoảng 800 đô
T: Thế còn cái phần chênh lệch đó chính phủ làm gi?
O: Oh, chúng tôi tôn trọng quyền riêng tư của người dân, chúng tôi không can thiệp chuyện đó. Thế ở VN, lương tối thiểu thế nào?
T: 800 ngàn đồng
O: Và trung bình một người VN xài hết bao nhiêu một tháng
T: Khoảng 3 triệu.
O: Oh My God, thế người dân lấy đâu ra bù vào phần thiếu hụt đó?
T: VN chúng tôi cũng như Mỹ, rất tôn trọng quyền tự do của công dân. Chính phủ không can thiệp vào chuyện đó.
O:

Chuyện kể chủ tịch Triết sang Mỹ nói chuyện với TT Obama về an sinh xã hội

Chuyện kể chủ tịch Triết sang Mỹ nói chuyện với TT Obama về an sinh xã hội. Triết hỏi Obama:

T: Ở nước Mỹ lương tối thiểu là bao nhiêu?
O: 1300 đô la
T: Thế trung bình một người Mỹ mỗi tháng xài hết bao nhiêu?
O: Khoảng 800 đô
T: Thế còn cái phần chênh lệch đó chính phủ làm gi?
O: Oh, chúng tôi tôn trọng quyền riêng tư của người dân, chúng tôi không can thiệp chuyện đó. Thế ở VN, lương tối thiểu thế nào?
T: 800 ngàn đồng
O: Và trung bình một người VN xài hết bao nhiêu một tháng
T: Khoảng 3 triệu.
O: Oh My God, thế người dân lấy đâu ra bù vào phần thiếu hụt đó?
T: VN chúng tôi cũng như Mỹ, rất tôn trọng quyền tự do của công dân. Chính phủ không can thiệp vào chuyện đó.
O:

Sunday, April 3, 2011

some php file manager app

có thể dùng để play music, photo, video
http://gerd-tentler.de/tools/filemanager

phân quyền, chia nhóm
http://sf.net/projects/extplorer
http://www.ajaxplorer.info
http://bfexplorer.sf.net/

có thể kết hợp với các editor (vd; ckeditor, tinymce...)
http://kcfinder.sunhater.com

single file
http://phpfm.sf.net and http://protocolour.co.uk – php file manager
http://solitude.dk/filethingie/download
http://sourceforge.net/projects/simpledirectory

sắp xếp theo: good trc, bad sau

some php file manager app

có thể dùng để play music, photo, video
http://gerd-tentler.de/tools/filemanager

phân quyền, chia nhóm
http://sf.net/projects/extplorer
http://www.ajaxplorer.info
http://bfexplorer.sf.net/

có thể kết hợp với các editor (vd; ckeditor, tinymce...)
http://kcfinder.sunhater.com

single file
http://phpfm.sf.net and http://protocolour.co.uk – php file manager
http://solitude.dk/filethingie/download
http://sourceforge.net/projects/simpledirectory

sắp xếp theo: good trc, bad sau