BeansTag – Official release

After almost 2 years, the BeansTag module finally get through the review process and it is not officially released! If you want to find a simple tool to add page title and meta tags on your Drupal 7 website, BeansTag may be a good option for you.

BeansTag is a page title, meta tag and meta description management tool. You could add the above attributes to any path alias and they would be shown in the webpage. It fully support any pages including views, panel pages as well as nodes.

BeansTag also support multiple language since the language prefix in the path alias is also included when rendering the BeansTag.

Continue reading BeansTag – Official release

jQuery – Freeze HTML table header and the left columns

A few months ago, i am working on a website project which contains a very wide HTML table. The client wants to keep the top row and the two columns on the left hand side of the table sticky. There is no proper way to do it but and the only solution i could found is using a jQuery library written by Conan Albrecht. The original post could be found in the link below but the source link is no longer valid.
A JQuery Plugin For Freezing Table Rows/Columns

Luckily i have a copy of the lib and you can download here.
Continue reading jQuery – Freeze HTML table header and the left columns

陶傑 – 八十年前

《南周》事件還沒了完。只是一群知識份子想做個「憲政夢」罷了,沒有越軌,哪知道得罪了「習李新政」。

了解這個民族的人,像本人,絕不會大驚小怪。今天為此喊冤的,是不懂得這個國家的輪迴史。

一九三二年底,有一本《東方雜誌》,為慶祝一九三三年元旦,主編胡愈之向全國四百位名人發出一封徵稿信,題為:「一九三三年新年,大家做一回好夢」:

「在這昏黑的年頭,我們的整個國家民族也都淪陷在苦海之中。我們詛咒今日,我們卻還有明日。假如白天的現實生活是緊張而悶氣的,在這漫長的冬夜裏,我們至少還可以做一二個甜蜜的舒適的夢。夢是我們所有的神聖權利啊!」

《東方雜誌》的徵稿信提出兩個問題:

一,先生夢想中的未來中國是怎樣?(請描寫一個輪廓或叙述未來中國的一個方面)。
二,先生個人生活中有什麼夢想?(這夢想當然不一定是能實現的)

Continue reading 陶傑 – 八十年前

陶傑 – 我會回來

阿爾及利亞的西方天然氣人質大屠殺,人質死了近廿人,存活者緊急撤退,但英國天然氣公司的主管說:我會回來。

這句話豪氣衝天。已經屍橫遍野,還要回來?當然。有利潤在的地方,不論代價多少,都會回來。換了是香港的公司,早已魂不附體,家屬嚎哭,議員叫「問責」,投訴這個,檢討那樣,加上「黑色旅遊警示」了。但是這個主管說:我會回來。

這是帝國和殖民地的分別。既然是開拓和宣播,必有不可預測的阻力和風險。十九世紀的傳教士去中國佈道,許多給抓起來殺了頭,叫做「教案」。河北天津、山東曹州,拳匪鬧北京,無數教案,死了不知多少人。但從此聖經就此隔絕了嗎?沒有。今天,香港學生有得讀聖保羅和拔萃,家長拚命搶得報名表,多得捐軀殉道的許多前人。
Continue reading 陶傑 – 我會回來

Drupal 7 – Add reset button to Webform

The Drupal Webform does not have the reset button by default. If you want to have one, you can create custom module to alter the form.

function <module>_form_alter(&$form, $form_state, $form_id) {
  if (strpos($form_id, 'webform_client_form_') === 0 || ($form_id=='user_register_form')) {
    $form['actions']['reset'] = array(
      '#type' => 'button',
      '#value' => t('Reset'),
      '#weight' => 100,
      '#validate' => array(),
      '#attributes' => array('onclick' => 'this.form.reset(); return false;'),
    );
  }
}

 

The above code will add the reset button to all Webform as well as the user registration form.

Done =)

Reference: Drupal Webform – ‘reset’ button

CSS – Auto height adjustment for div which contains floating elements

Update @ 2014-11-13: In web development, this approach is very common and usually we called it the clearfix hack.
CSS-Tricks – Force Element To Self-Clear its Children

We always use the float property to arrange the layout of a webpage. Consider the following html.

<style type="text/css">
  .child {
    float: left;
    padding-top: 20px;
    background-color: grey;
  }
</style>

<div id="parent">
  <div class="child" style="height: 80px;">text 1</div>
  <div class="child" style="height: 70px;">text 2</div>
  <div class="child" style="height: 60px;">text 3</div>
  <div class="child" style="height: 50px;">text 4</div>
</div>

<div>Followihg div</div>

Continue reading CSS – Auto height adjustment for div which contains floating elements

陶傑 – 淚芭蕾

莫斯科大劇院芭蕾舞團總監,被人淋了鏹水。不下於印度的輪姦案,所謂「金磚四國」,其中一個固然永不必再論,俄國和印度,不論經濟多增長,證明離現代文明尚遠。

俄國的芭蕾舞有兩大流派:以聖彼得堡為中心,比較受法國宮廷影響,由沙皇傳下來,風格古典而拘謹,叫做基洛夫芭蕾團(Kirov)。基洛夫是一九三四年被史達林暗殺的共黨異議分子。另一派以莫斯科為基地,芭蕾的風格有點改革,舞者的動作從下身釋放出來,豪放一些,上軀也增加一點動力,有現代風。

就像烹飪,南北菜系,俄國芭蕾這東西兩宗,基洛夫與歐洲相近,比較受西方歡迎,莫斯科大劇院這一支,卻另有俄國本土風格。

芭蕾舞是殘酷的藝術,尋常女兒家,沒有天份和意志,不要進這一行。美國黑人女明星沙丹娜(Zoe Saldana)說:「芭蕾我沒再學下去,因為我發現有一部份自我死了。」(I had to quit ballet because it felt like a part of me was dying inside me)這是很撕心裂肺的真話。小女孩學芭蕾,像中國的柔軟體操培訓,不斷受到苛斥和否認。不,不是這樣,重新再來。不,你做得不夠好。一雙芭蕾舞鞋,是血淚灌溉成的一株百合,即使成長了,芳香也帶着飲泣,淒美不忍細看。
Continue reading 陶傑 – 淚芭蕾

Dream BIG and go for it =)