Tag Archives: Drupal Development

Drupal 7 – Render a view with contextual filter argument programmatically

Some days ago, i write a blog post about how to render a Drupal 7 block programmatically.
Drupal 7 – Render a Block programmatically

If the block is created by Views, there is a simpler solution provided by the Views API. And we can also pass the contextual filter argument too.

print views_embed_view(<view machine name>, <display id>, <arg 1>);

 

Done =)

Reference: Outputting a Drupal 7 View programmatically with Contextual Filters (arguments)

Drupal 7 – Increase the number of values per field

A long time ago, i have a post about hacking into the CCK module so we could have more options when settings the number of values per field in the field setting page.
Drupal – Increase Views Relationship Delta Limit

This is a dirty approach as mentioned by eosrei.

So in Drupal 7, we can do it by creating a custom module and alter the field_ui_field_edit_form. Let’s implement the following hook_form_FORM_ID_alter() in a custom module.
Continue reading Drupal 7 – Increase the number of values per field

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