Skip to main content

Introducing Field Collection Tabs formatter

Ever needed to output your field collection items in a tabset, one item per tab? Customisable tab titles based on fields on the collection items? Then you need our latest contrib module Field Collection Tab formatter.

by lee.rowlands /

We're proud to announce our latest contrib module, field collection tabs formatter - which, as you'd expect from the name, provides a tabs formatter for field collection items.

The module uses core's jquery.ui.tabs to output a field collection field as a tabset, one collection item per tab.

You can even nominate a field from the field collection to use as the tab title.

Here's a screenshot of the display settings.

And here's how it looks, unthemed.

We hope you enjoy this latest contributed module from our team, as always if you have any issues or suggestions - please use the issue queue.

Posted by lee.rowlands
Senior Drupal Developer



Comment by Ahmad Haggag


Excellent work! Thanks.

Comment by Lotfi


to do it, and it was working good for my dev site. BUT when I went to a multi-site inasollttian with subdomains, , , etc the array method would break and drupal would default to the database for the main site . This drove me crazy for hours, trying to figure out what was happening, was the subdomain calling the correct settings.php file, etc .?I saw your posting but it didn't sink in until an hour later. Just modify the $db_url in the module code! Brilliant!This way I don't have to instruct users to modify their db_url in settings, and even if they do, I can still add to the array using your code.So for others with my problem, this is what is happening in Jon's code:// put this section of php code at the top of your .module file//access the php variable $db_url from it's global $db_url;/* if it's not an array already, make it an array, and set the key named 'default' to be the original value of the db_url*/if ( !is_array($db_url) ) { $db_url = array( 'default' => $db_url );}// set your values for the alternative database$protocol = 'mysqli'; // or use variable_get() to get the variable you set on your settings page$user = 'user';$pass = 'password';$host = 'localhost';$db = 'alternate_db';/* then add an element to the db_url array building the proper format for a db connection string*/$db_url['alternate'] = "$protocol://$user:$pass@$host/$db";// that is the end of the php code you need at the top of the .module file.Note that code chunk will be called each time a page is requested. but it's small and elegant code so it won't hurt performance.Now when you are writing functions in your module files and you need to switch to your alternate database, use the rest of the code snippet as follows://inside your function/* call the db_set_active function and pass it the value of the key in the db_url array that you setup before. that function will get the value of the previous db_url and return it and then switch to the alternative db_url value.*/$previous = db_set_active('alternate'); // do stuff in your function with the alternative database/* now switch back to whatever database was active before you switched to your alternative database*/db_set_active($previous); /* you can also call that function without any arguments, and it will connect to the database specified by your key named "default"*/// db_set_active();Sorry for writing such a long book, but I can't stand the lack of good documentation in Drupal, so I wanted to help others. Let's hope Drupal 7 won't be too painful