Tag Archives: Drupal

Drupal 7 – Render Views Exposed Filter programmatically

Update at 2015-04-27: Another suggestion by Petu which could render the filter as a block programmatically.

Update at 2014-09-18: An simpler way to do that is to enable the Exposed form in block in the view settings and then render the block as suggested by plano.com.

The following piece of code render the Views Exposed Filter.

$view = views_get_view('<view name>');
$display_id = 'page';
$view->set_display($display_id);
$view->init_handlers();
$form_state = array(
  'view' => $view,
  'display' => $view->display_handler->display,
  'exposed_form_plugin' => $view->display_handler->get_plugin('exposed_form'),
  'method' => 'get',
  'rerender' => TRUE,
  'no_redirect' => TRUE,
);
$form = drupal_build_form('views_exposed_form', $form_state);
print drupal_render($form);

 

Done =)

Reference:

Drupal 7 – Get Facebook Page feeds by Aggregator

You can get the Facebook Page content by the following URLs:

RSS 2.0
http://www.facebook.com/feeds/page.php?format=rss20&id=[fb-page-id]
Atom 1.0
http://www.facebook.com/feeds/page.php?format=atom10&id=[fb-page-id]

 

Where the [fb-page-id] could be found by browsing your Facebook Page -> Edit Page. That URL should have the following format.

https://www.facebook.com/pages/edit/?id=%5Bfb-page-id%5D&sk=basic

Continue reading Drupal 7 – Get Facebook Page feeds by Aggregator

Drupal 7 – Create a taxonomy term selection list of a specific vocabulary @ 2

We talk about how to generate a taxonomy term selection list in the following post.
Drupal 7 – Create a taxonomy term selection list of a specific vocabulary @ 1

So we continue to add the jQuery/Javascript code such that when the term is selected, the browser will open the corresponding term page.

The following piece of jQuery/Javascript is redirect you to the selected term page.
Continue reading Drupal 7 – Create a taxonomy term selection list of a specific vocabulary @ 2

Drupal 7 – Create a taxonomy term selection list of a specific vocabulary @ 1

Next: Drupal 7 – Create a taxonomy term selection list of a specific vocabulary @ 2

I want to create a HTML selection list which contains the taxonomy terms of a vocabulary. When a option is selected, the browser will go to the selected term page. In this post, i would like to share how to generate a selection list by PHP.

I have a vocabulary which has terms in 2-level. The selection list could generated as follow.
Continue reading Drupal 7 – Create a taxonomy term selection list of a specific vocabulary @ 1

Drupal 7 – Override the .tpl.php in Advacned Forum

Advanced Forum has some default themes which are located @ sites/all/modules/advanced_forum/styles/<theme>.

Naked/Naked Stacked themes could be used for customization. So copy the .tpl.php which you want to customize in the sites/all/modules/advanced_forum/styles/naked folder to your theme folder.

For example, i want to customize the advanced-forum.naked.author-pane.tpl.php.
Continue reading Drupal 7 – Override the .tpl.php in Advacned Forum

Drupal 7 – Customized comment.tpl.php for specific content type

The comment.tpl.php is located @<drupal-root>/modules/comment/comment.tpl.php. If you want to customize it for different content type. Copy it to your theme folder and rename it to

  • comment–node-<content-type>.tpl.php

For example, the machine name of Article is article. So the file name should be comment–node-article.tpl.php.

Done =)

Reference:

PHP – Get the next month by strtotime

I am working on a Hotel Booking website. The booking feature is provided by Hotel Booking System for Ubercart. But this module is not actively maintained so there are some bugs which i have to fix it for myself.

One of the bug is about strtotime(‘+1 month’). Intuitively, you may think you could get a date of next month. But here comes the problem. Assume you are now on 31st Jan. Since February only has 28 days (sometimes 29), strtotime(‘+1 month’) will return 3rd Mar.
Continue reading PHP – Get the next month by strtotime

Drupal 7 – Add extra text on the LightBox2 popup

Update @ 2014-01-24: Instead of hacking into LightBox2 module, you can use the hook_js_alter() as suggested by Sunny Gambino. Thanks Sunng. =D

 

LightBox2 will show the image title as caption in the popup.
drupal7-add-text-to-lightbox2-1
 

But apart from the title, i would like to add extra text to the popup. Unfortunately there is no proper way to do it. So i have to hack into the lightbox.js.
Continue reading Drupal 7 – Add extra text on the LightBox2 popup