Tag Archives: Drupal 7

Drupal 7 – Show YouTube video in LightBox2

The following HTML allows you to show a video in LightBox2.

<a href="http://www.youtube.com/embed/<VIDEO ID>?autoplay=1" rel="lightframe">Click me</a>

 

We could control the size of the popup.

<a href="http://www.youtube.com/embed/<VIDEO ID>?autoplay=1" rel="lightframe[|width:320px; height:240px;]">Click me</a>

 

Done =)

Reference:

Drupal 7 – Menu item is disabled after saving the node in different language

i found a bug with the i18n module. Assume i have a node in Traditional Chinese and i edit it in English. The menu item set Menu settings will be disabled after save.

A simple workaround is to alter the node edit form such that the user will be redirected to the language same as the node.
Continue reading Drupal 7 – Menu item is disabled after saving the node in different language

Drupal 7 – Create your own theme function on your custom block

More than a year ago, we have talked about some basic theming in Drupal 6.

In Drupal 7, there are some changes on the theming functions as well as the block hooks. So here is a slightly modified versions from the example of Drupal – Introduction to Drupal Theming @ 3. The logic behind is exactly the same.

ykyuen.info
Continue reading Drupal 7 – Create your own theme function on your custom block

Drupal 7 – Customize Ubercart invoice email template

You can find the Ubercart invoice email template files @ sites/all/modules/ubercart/uc_order/templates. You could copy and edit the uc-order–customer.tpl.php to fit your needs but you could not select it @ E-mail customer checkout notification > Email an order invoice in Rules. This is because you have to implement the hook_uc_invoice_templates() before the new template is selectable.
Continue reading Drupal 7 – Customize Ubercart invoice email template

Drupal 7 – Pass values from PHP to Javascript

During Drupal development, sometimes we may need to manipulate some server data in Javascript. In this case, we could create a custom module to retrieve the database data and pass it to browser such that we can it it in Javascript.

1. Implement the hook_init().

function <module-name>_init() {
  drupal_add_js(
    array(
      'eureka' => array( // we should use module name for best practice
        'data' => array(
          'Name' => 'ykyuen',
          'Blog' => 'Eureka!',
          'URL'  => 'https://eureka.ykyuen.info/',
        ),
      )
    ),
    'setting'
  );
}

Continue reading Drupal 7 – Pass values from PHP to Javascript

Run Drupal 7 in Nginx

After so many days we have talked about setting up Nginx, PHP-FPM, MariaDB and some PHP caching. We can now try to run a Drupal instance on them. Before we starts, let me listed out all the previous posts.

 

It’s time to start the Drupal installation.
Continue reading Run Drupal 7 in Nginx