CSS – Vertical align the div content

We can vertical align the content of inside a <div> by the following CSS.

v-align-div {
  display: table-cell;
  vertical-align: middle;
}

 

Here is a simple HTML example which demonstrates the vertical alignment. Continue reading CSS – Vertical align the div content

Drupal 7 – Customize the user login block

In Drupal 7, there is a user login block. We can customize that block using the hook_form_FORM_ID_alter(). You can create a custom module or implement it directly in the theme template.php.

Here is a simple example written by Liam McDermott. You can add this in the template.php and replace THEMENAME by your theme name.
Continue reading Drupal 7 – Customize the user login block

國民教育?咪玩啦

好久沒有亦不多寫時事的文章,因為自己的墨水實在有限。

但今日好想寫,事源是不愛看報紙的我在出大恭時看到一篇名為「洗腦?咪玩啦」的社論,我覺得可以用來作一個例子去了解邏輯推理是什麼一會事,沒有邏輯推理,便沒有討論的價值。

 

首先引述「洗腦?咪玩啦」這篇文章的開首的內容:

「習慣性質疑証」已成反對派喉舌慣用的伎倆,總之,只要新政府有甚麼新政策,未經深入調查,甚至未看要綱要,就必先擘大喉嚨,質疑其「陰謀」,像德育及國民教育,儘管教育局局長吳克儉撰文,表明「中國模式」並非一成不變,而國情亦容許兼容不同意見,培養獨立自主學生……

然而,反對派喉舌硬要炒作德育及國民教育是「洗腦教育」 — 在一個開放的社會,觀念經常隨時代潮流而轉變,真要「洗腦」,談可容易!

我不知道醫學上有沒有「習慣性質疑証」,但以上內容絕對稱不上有任何討論價值,因為那位作家所稱呼的“反對派”己經主觀地被標明為逢政府必反,這些“反對派”只有「伎倆」,沒有理據。在此情況下,基本上沒有討論的空間和必要。

我在討論的技巧 @ 1提及過,討論時要留意自己主觀的情感,非理性地標籤別人只會阻礙討論的空間。上述作家說“反對派”德育及國民教育炒作為「洗腦教育」,他又可嘗不是將“反對派”炒作為「習慣性質疑証」呢?這不是討論而是嗌交。
Continue reading 國民教育?咪玩啦

陶傑 – 洗腦離奇事件

在人類歷史上,「洗腦」是常見的政治事業。

歐洲中世紀神權獨大,洗腦的工具是聖經。今天,阿蓋達的恐怖組織,洗腦用原教旨的可蘭經。被洗了腦的人,其最可怕之處,是不知道自己被洗了腦。

對於人生、世界、是非的判斷,本來像東南西北,明明有四座城門,四條通道,四個進出口,多角度,多方位,但被洗了腦的人,四座城門的出口永久關閉了南西北三座,死死的,只有東面一個方向。

在中國人社會,被洗過腦的人多不勝數。這些人本來天資已經不高,年輕時誤投一種極端而有煽動力的信仰,很早就關上了其他的思路方位,只剩下「東」。他們很早就喪失了想像力,加上缺乏西方的邏輯訓練,認定了一個救星,終生只向那個方位單線直行。
Continue reading 陶傑 – 洗腦離奇事件

Drupal 7 – form_set_error does not show

I have a custom form and i render the form using drupal_get_form() inside the .tpl.php. One day, i find that when the submission could not pass the validation, only the failed field was highlighted but without the error message. Then i find the following post suggesting that i should called the drupal_get_form() in the .module file or preprocess function instead of the .tpl.php.
form_set_error Not displaying error after invalid form submission

So i put the drupal_get_form() call in the preprocess function and set the form in the $vars so it could be printed in the .tpl.php. But that still could not solve the problem. Finally i come up with a simple solution which is just adding the following line in the .tpl.php.

<div><?php print theme_status_messages(array('display' => 'error')); ?></div>

 

Done =)

Reference:

陶傑 – 國王與我

梁班子「國民教育」教科書,被指向香港中國下一代政治洗腦,攻擊西方民主,指美國「政黨惡鬥,人民當災」。中國就不同了,是「進步、無私、團結的執政集團」

貶低別國,頌揚本國,這種「國民教育」,像百老滙經典音樂劇「國王與我」裏的一場戲。

「國王與我」講十九世紀英國宮廷女教師安娜,受僱於暹羅王,來到曼谷王宮,教暹羅王幾十個子女西方文明,拯救他們脫離愚昧無知。

第一天,安娜看見王妃在教孩子地理課,掛一張暹羅製的印支地圖,圖中的暹羅國,畫得不符比例地特別大,其他的國家,都縮得特別小。王妃指着正中的大暹羅,尖聲說:「暹羅,是世界的中心,很大!」(Siam, the centre of the world, very big!) 然後又比劃着近鄰的緬甸,叫嚷:「緬甸,小!」(Burma, small!) 小孩都拍手,歡笑一片。
Continue reading 陶傑 – 國王與我

名言五十三

The worst illiterate is the political illiterate. He hears nothing, sees nothing, takes no part in political life. He doesn’t seem to know that the cost of living, the price of beans, of flour, of rent, of medicines all depend on political decisions. He even prides himself on his political ignorance, sticks out his chest and says he hates politics. He doesn’t know, the imbecile, that from his political non-participation comes the prostitute, the abandoned child, the robber and, worst of all, corrupt officials, the lackeys of exploitive multinational corporations.

Bertolt Brecht


 

在各種無知中,最差勁的是「政治無知」。他聽而不聞、視而不見,他從不參與任何政治活動。他彷彿懵然不知,種種生活費用,如大豆價格、麵粉價格、租金、醫藥費等,全都與政治決定息息相關。他甚至對自己的政治無知引以為傲,挺起胸膛,高聲說自己討厭政治。這愚人並不知道,基於自己的政治冷感,社會出現了淫業、棄童、搶匪--更可悲的是出現了貪官污吏,他們對剝削社會的跨國企業阿諛奉承。

布萊希特


 

Drupal 7 – Get the relative and absolute public file path

Previously we talked about how to get the absolute file path of your Drupal installation.
Drupal – Get the absolute file path of your Drupal installation

There are also other ways to get different file paths in Drupal. Suppose the Drupal webroot path is /var/www/drupal.

print variable_get('file_public_path', conf_path() . '/files');
// output: sites/default/files 

print drupal_realpath(file_default_scheme() . '://');
// output: /var/www/drupal/sites/default/files

print realpath(".");
// output: /var/www/drupal

 

Done =)

Dream BIG and go for it =)