With Display Suite Extra, we can turn on the View mode switcher which allows site visitor to view different view mode of a content type ajaxly.
Continue reading Drupal 7 – Display Suite Extra switch view mode doesn’t take content id from URL for contextual filter
In the HKNA project, i exposed a flag in a view but it turns on the available option names are True and False instead of Yes and No.
Continue reading Drupal 7 – Override the Flag option names in Views Exposed Filter using String Overrides
The Views Send module integrated with Drupal Views such that you can select a group of email addresses with the Views filter and then send a batch of emails.
1. Download and enable the Views Send module module.
2. Create a new user view in Table format.
3. Add the User: E-mail as well as the Global: Send e-mail field.
Continue reading Drupal – Send mass email to node email field using Views Send module
Yesterday we talked about exporting data using the Views data export module.
Drupal 7 – Export view data CSV, XML, XLS by Views data export module
The module also provides a Drush command such that you can run the export command in the server which is convenient for backend integration.
The following command is stated in the project page.
- drush views-data-export [view-name] [display-id] [output-file]
Continue reading Drupal 7 – Export data using Views data export module with Drush command
In Drupal 7, we can easily create export Views data by the Views data export module. Say, we want to export all current nodes with title and post date.
1. Download and install the module.
Continue reading Drupal 7 – Export view data CSV, XML, XLS by Views data export module
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>);
Reference: Outputting a Drupal 7 View programmatically with Contextual Filters (arguments)
Not long a ago, i have 2 posted about rendering Blocks and Views in PHP.
We can render the Drupal 7 block by PHP in another way.
Continue reading Drupal 7 – Render a Block 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';
$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);
Sometimes the content types we created are only used in Views. We don’t want to have the node view page for those content. The following solution would turn those unwanted node view pages to 404 not found.
Create a custom module and implement the hook_node_view() as follow.
Continue reading Drupal 7 – Disable the node view URL for some content types
Sometimes we may want to update multiple nodes at once. Views Bulk Operations may help if you want to set the same value for a field of multiple nodes. But if you want to set different values among a set of nodes, then Views Bulk Operations could not help.
In Drupal 6, the Editview module may help but unfortunately there is no Drupal 7 version. An alternative solution could be done by editablefields module.
1. Download and enable the module. (I used the 7.x-1.x-dev version)
2. Create a view with table format. (This is not necessary but better user interface)
Continue reading Drupal 7 – Update multiple nodes at once in a Views