Tag Archives: Postaday2011

Drupal – Form Path Problem of Exposed Filter Block in Panel Page

In Views, we can make the exposed filter into block and therefore we can select it for Panel page. But this would not work because after the filter form submission, it will redirect to the view page rather than the current panel page.

Luckily, i found a solution to resolve the issue. Continue reading Drupal – Form Path Problem of Exposed Filter Block in Panel Page

陶傑 – 仇富新識

香港和中國大陸流行「仇富」

仇富問題,需要一點理論。方今之仇富,不是要搞社會主義,與當年列寧共產仇恨工業資本家不同。

首先要定義一個「富」字。昨天的富,因世界尚在工業時代,美國的福特、卡耐基,中華民國的榮德生、包玉剛,皆是用一雙手幹出來,一雙腿跑回來,前半生一件汗衫,一雙舊鞋,把機器、汽車、輪船,辛苦的打賺而得。

那樣的富,美國沒有事,一直都鼓勵,在遠東,偏偏要煽動農民鬥地主的愚昧之仇,三千年的文化,就此毀滅,七八億人口,還原為思想的癡呆。

但是今日之「仇富」,要問一句,「富」從何來? Continue reading 陶傑 – 仇富新識

Drupal – Add HTML Markup in Form

I would like to add some HTML elements in the login form. This can be done by hook_form_alter() and the markup could be added as follow.

function <your module>_form_alter(&$form, &$form_state, $form_id) {
  //print $form_id.'<br/>';
  if ($form_id == 'user_login') {
    //print_r($form);
    $form['html_markup'] = array('#value' => t('<a href="https://ykyuen.wordpress.com">Eureka!</a>'));
  }
}

 

Done =)

Reference: Drupal 6 Form API Reference

PHP – Swap Array Elements By Array Keys

The following PHP function could swap the array elements by the array keys.

function array_swap_assoc($key1, $key2, $array) {
  $newArray = array ();
  foreach ($array as $key => $value) {
    if ($key == $key1) {
      $newArray[$key2] = $array[$key2];
    } elseif ($key == $key2) {
      $newArray[$key1] = $array[$key1];
    } else {
      $newArray[$key] = $value;
    }
  }
  return $newArray;
}

Continue reading PHP – Swap Array Elements By Array Keys

.htaccess – Invalid command ‘AuthUserFile’, perhaps misspelled or defined by a module not included in the server configuration

I have a previous post which demonstrates how to add HTTP Authentication by .htaccess.
.htaccess – Setting Password For Your Web Folder

But if it does not work and shown the following error in the Apache error log

  • /home/ykyuen/public_html/.htaccess: Invalid command ‘AuthUserFile’, perhaps misspelled or defined by a module not included in the server configuration

Continue reading .htaccess – Invalid command ‘AuthUserFile’, perhaps misspelled or defined by a module not included in the server configuration

Drupal – Customized User Registration/Login/Forgot Password Page with Panel

Update @ 2012-12-30: Here is much simpler approach proposed by tombehets. Thanks =D

/**
 * Implements hook_menu_alter().
 */
function mymodule_menu_alter(&$items) {
  //redirect user/register to register, our custom panel.
  $items['user/register']['page callback'] = 'drupal_goto';
  $items['user/register']['page arguments'] = array('register');
}

 

Panels is a very useful module in Drupal which helps us to customized page view with specific layout. Unfortunately, it does not support the User Login, User Registration and Forgot Password pages.

Luckily, I found a simple workaround on Google. The idea is just creating a custom panel page as usual and add a custom panel pane with the desired form as follow. Continue reading Drupal – Customized User Registration/Login/Forgot Password Page with Panel