Drupal 7 – Add the Facebook Connect login button on user registration and login page

In the past 2 days we have talked about the use of Facebook Connect module.
Drupal 7 – Allow Facebook login using Facebook Connect
Drupal 7 – Override the Facebook Connect login button theme

In this post, i will show you how to render the Facebook Login button programmatically in the Drupal user registration and login page.

The following code will render the Facebook Login button programmatically.

$user_profile = fbconnect_user_profile();
$attr = array();
if (variable_get('fbconnect_fast_reg', 0) && variable_get('fbconnect_reg_options', 0)) {
  $attr = array('perms' => 'email');
}
$ss__facebook_connect = fbconnect_render_button($attr);

Continue reading Drupal 7 – Add the Facebook Connect login button on user registration and login page

Drupal 7 – Override the Facebook Connect login button theme

We can implement Facebook Login using Facebook Connect. For more info, please refer to
Drupal 7 – Allow Facebook login using Facebook Connect

For those who wants to override that Facebook Login template, add the following function in your theme template.php and and customize it as u wish.
Continue reading Drupal 7 – Override the Facebook Connect login button theme

Drupal 7 – Allow Facebook login using Facebook Connect

The website i am working now needs to have Facebook Login. I found 3 modules which could implement that feature.

 

Facebook Connect requires the Facebook PHP SDK and the configuration is quite user friendly and this is also the module which i used.

Facebook OAuth provides an API for authentication and does not need the Facebook PHP SDK. It fits for Drupal developesr who wants higher level of customization.

Drupal for Facebook seems to target Facebook application development. I didn’t tried it.
Continue reading Drupal 7 – Allow Facebook login using Facebook Connect

陶傑 – 香港是我家

香港房地產會不會跌?豪宅的市場,一定不會。

因為大陸的熱資,看看地圖,十四億人口的一隻大公雞,漏斗一樣,只有香港這個洩洪口。不管黑道白道,合法非法,中國錢一定流灌來香港的豪宅市場。

不錯,高官和礦主,家財到幾百億的時候,可以在倫敦、紐約、洛杉磯買豪宅。在西方白人文明國家的心臟地帶,像倫敦的武士橋和肯盛頓、紐約的曼哈頓、洛杉磯的聖他蒙尼卡和比華利山,擁有一幢獨立花園洋房,地位、形象、身價,像擁有牛津大學學位一樣,比起香港科大 Kong U的渣甸山、扯旗山等,高尚許多倍。
Continue reading 陶傑 – 香港是我家

阿基米德的浴缸 – 突破性思考的藝術與邏輯

作者: David Perkins

之前未有買新書,所以再看一編這本大學時所買有關突破性思考的書,原來已經差不多有十年。

作者 David PerkinsMIT 人工智慧學博士,要研究人工智能其中一個方法就是研究我們的大腦如何運作,思考是什麼? 而本書正是作者分析靈光一閃 (也就是Eureka!,哈哈) 是怎樣的一回事。

當我們面對問題而一籌莫展的時候 (例如 IQ 題),到底有沒有一種思考的方法幫助我們找到答案? 有些人很快就找到出路,亦有些人窮盡腦汁也如答案無緣,對作者來說突破性思考在困局裡產生了關鍵的作用。

本書的中心主要將困局類比作克郎代克 (Klondike/Clondike) 空間克郎代克是加拿大一個淘金的地方,來到這裡淘金夢者將面對四大挑戰:

  • 處處可能的荒野
  • 漫無頭緒的高原
  • 峽谷裡的探索
  • 錯誤預期的綠州

 

要注意的是邏輯推理能力對這克郎代克空間裡的四大挑戰並沒有顯著的優勢,惰性知識 (Inert knowledge) 反而往往讓我們泥足深陷,如何可以突破這些陷阱正是本書的重點。

作者在最後一章指出克郎代克空間這模型並不局限於描述突破性思考達爾文 (Charles Darwin) 的進化論道金斯 (Richard Dawkins) 描述社會演化的 (或稱模因,英文: Meme) 同樣拼命地掙脫克郎代克空間

為何這世間會有突破性難題的存在? 我對作者其解釋所帶出的自我組織臨界狀態 (Self-organized criticality) 特別深刻,有機會一定要再深入研究一下這有趣的理論。

Drupal 7 – Render the Nice Menus programmatically

The following piece of code will print the Nice Menus block.

$menu = theme('nice_menus', array('id' => 1, 'direction' => 'down', 'depth' => 1, 'menu_name' => '<menu-machine-code>', 'menu' => NULL));
print $menu['content'];

 

you can input any value in the <id> parameter and the rendered menu will have the HTML tag id = nice-menu-<id>. Just make sure there is no duplicated nice menu id in the same page.

Done =)

Reference: How to display nice_menus programmatically in Drupal 7

jQuery Isotope – Remove Isotope items without triggering relayout

Recently i have been working on a frontend layout task. The two jQuery plugins, Isotope and Masonry written by David DeSandro, are wonderful for laying your content in neat order. Isotope is an advanced version of Masonry and provides more powerful features. If you are new to both, you could try Masonry first.

Let’s back to the topic today. Both Isotope and Masonry provide the remove() function to withdraw the item from the dynamic layout. If you are using Masonry, the layout does not rearrange the items after the removal. On the other hand, the more powerful Isotope will relayout after the items are deleted. Actually this is a more desirable feature but this time i just want to delete those unwanted items without triggering the relayout.
Continue reading jQuery Isotope – Remove Isotope items without triggering relayout

Dream BIG and go for it =)