Drupal 7 – Create a Datetime field in hook_schema() @ 1

Next: Drupal 7 – Create a Datetime field in hook_schema() @ 1

If your custom module requires an additional table in the Drupal database, you have to create the .install file and define the schema inside it. In Drupal 7, the datetime field is no longer support by the Drupal Schema API. If you want to create a datetime field, you have to use the mysql_type or pgsql_type. Here is an example.
Continue reading Drupal 7 – Create a Datetime field in hook_schema() @ 1

Drupal 7 – Mutiliple selection list for taxonomy using Hierarchical Select

Taxonomy is a must have tool for grouping relevant content together. On the other hand, with the help of Views and exposed filter, user could easily list out the content with specific taxonomy.

But when a taxonomy has more than 1 levels, the filter option list may get too long and become less user friendly. In the past, i tried to make a multiple selection lists by applying some Javascript and jQuery on the exposed filter. It turns out that the result is quite bad.

Recently i found that there is a module which could turn the multiple levels taxonomy into multiple selection lists. It is called Hierarchical Select written by Wim Leers who is also the author of Drupal CDN module. Let’s try it now.
Continue reading Drupal 7 – Mutiliple selection list for taxonomy using Hierarchical Select

CSS – Make font-size smaller than 12px in Chrome

In Chrome, the displayed text has a minimum font-size 12px even thought you set a smaller value in CSS. This is because the Chrome browser has a auto font adjustment.

So if you want to style a text with font-size smaller than 12px, include the following line in your CSS file.

body {
  -webkit-text-size-adjust: none;
}

 

Done =)

Reference: StackOverflow – Font-size <12px doesn't have effect in Google Chrome

陶傑 – 神學和科學

神學科學,哪一個大?是有趣的問題。

在西方,神學科學一度勢不兩立,所以才有宗教裁判所審訊哥白尼。在神學的專權面前,科學一度低頭屈服。當然,不是所有的科學家都選擇為真理而殉難:布魯諾不屈,在火刑柱上燒死了,伽利略沒有,高壓之下,他選擇了大丈夫能屈能伸的策略,決定生命寶貴一些,尤其一個愚昧的黑暗世紀,不值得為一群蠢人犧牲性命。但是足足有五百年,神學迫害科學,火光熊熊之中,神學欠下科學許多人命血債。

二十世紀之後,科學復了仇,把神學擠到一角。火箭登陸月球,核彈能摧毀世界,試管嬰和複製羊,科學拓展了知識,知識就是權力。但是當科學知識的權力無限擴張,西方文明才想到神學,用神學來制衡。
Continue reading 陶傑 – 神學和科學

名言五十

The world is a dangerous place to live; not because of the people who are evil, but because of the people who don’t do anything about it.

Albert Einstein

The following quote is the chinese version with similar meaning.

知識分子應該對世界上任何不合理的現象表示自己的態度, 否則你就是幫兇。

愛因斯坦

jQuery – Using animate() with fadeIn() or fadeOut() at the same time

We know the difference between display: none and visibility: hidden as we talked about it previously.
jQuery – Animation on Visibility

The fadeIn() and fadeOut() jQuery functions are very convenient to use but they does not allow us to add animation during the fadeIn and fadeOut process. So we have to do it with a slightly different way.
Continue reading jQuery – Using animate() with fadeIn() or fadeOut() at the same time

jQuery – Animation on Visibility

Next: jQuery – Using animate() with fadeIn() or fadeOut() at the same time

We can hide and show any HTML elements by the fadeIn() and fadeOut() jQuery functions. Those elements will be set to display: none in CSS. Unlike setting visibility: hidden which the hidden element will still occupied some spaces in the rendered web page, the faded out element will disappear.

So if you want to have the fadeIn and fadeOut features while keeping the elements in the webpage, here is what you could do.
Continue reading jQuery – Animation on Visibility

Drupal 7 – Create a URL which display the latest node of a specific content type

I want to create a URL which will redirect to the latest node of a specific content type so i write a custom module. In this example, the content type car is used.

latest_car.info

name = Latest car
description = Create a URL which will redirect to the latest car node.
package = Eureka;
version = 7.x-1.0
core = 7.x

Continue reading Drupal 7 – Create a URL which display the latest node of a specific content type

Drupal 7 – Set Query Strings in the path for form_state[‘redirect’]

Previously we talked about adding query strings for drupal_goto().
Drupal – Escape the Hex Characters in drupal_goto()

When the form is submitted, we can decide the redirect path in the form_submit() function.
Redirect to node/1 after form submission

function <form id>_submit($form, &$form_state) {
  $form_state['redirect'] = 'node/1'
}

 
Continue reading Drupal 7 – Set Query Strings in the path for form_state[‘redirect’]