Tag Archives: Views

Drupal 7 – Get the field values in Style output in Views

Sometimes we may want to know what the field values inside the $row object in the Views Style output template. This could be done by.

$arr_rows = $view->style_plugin->rendered_fields;
<?php foreach($arr_rows as $key=>$arr_row) : ?>
<?php print $arr_row['field1']; ?>
<?php print $arr_row['field2']; ?>
<?php print $arr_row['field3']; ?>
<?php endforeach; ?>

 

Done =)

Reference: extract views $row values

Advertisement

Drupal – Send mass email to node email field using Views Send module

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

Drupal 7 – Export data using Views data export module with Drush command

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

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 – 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: