💾 Archived View for chirale.org › 2013-01-25_965.gmi captured on 2024-07-08 at 23:47:13. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2024-05-12)

-=-=-=-=-=-=-

Pair view fields content on a Drupal 7 view quick howto

I have two multiple text fields on a Drupal 7 content type.

=> https://chirale.wordpress.com/wp-content/uploads/2013/01/delta.jpg?w=246 multiple fields

I want to display those fields paired by delta in a view. Here the code I used in my module named mymodule.module.

 function mymodule_views_pre_render(&$view) { // pair field contents if ($view->name == 'my_view_name' && $view->current_display == 'my_view_display') { foreach ($view->result as $key => $res) { if ($res->field_data_field_youtube_url_delta != $res->field_data_field_youtube_url_description_delta) { unset($view->result[$key]); } } } } 

Thanks to hook_views_pre_render().

hook_views_pre_render()

I use this piece of code to pair Youtube URLs and plain text description  for a JSON output generated via Views Datasource.

Views Datasource

Remember to disallow multiple values when adding these fields to your view or you’ll get incoherent results.

https://web.archive.org/web/20130125000000*/https://chirale.wordpress.com/2013/01/25/pair-view-fields-content-on-a-drupal-7-view-quick-howto/delta/

https://web.archive.org/web/20130125000000*/http://drupal.org/project/views_datasource