Hello,

I've tried out using some of the modules for Field Collections/Views/etc. but have not been able to achieve what I need for formatting the table.

What I'm trying to achieve is this table structure:

Node Title
Node Description
Table:
-------------------------------------------------------------
| [section title header] | [pdf title] | [video title] | <- Main Heading with Column Titles
-------------------------------------------------------------
| [sub-section title] | [pdf icon] | [video icon] | <- One or more. If pdf file, show icon, otherwise leave blank. Same for video
-------------------------------------------------------------
| [sub-section title] | [pdf icon] | [video icon] | <- more...
-------------------------------------------------------------
| [section title header] | <- One, span all columns
--------------------------------------------------------------
| [sub-section title] | [pdf icon] | [video icon] | <- One or more.
--------------------------------------------------------------
| [sub-section title] | [pdf icon] | [video icon] | <- more...
--------------------------------------------------------------
| [section title header] | <- One, span all columns
--------------------------------------------------------------
| [sub-section title] | [pdf icon] | [video icon] | <- One or more.
--------------------------------------------------------------
| [sub-section title] | [pdf icon] | [video icon] | <- more...
--------------------------------------------------------------
......

Ideally, I'd like to keep this all in one content-type, think a "course". Any ideas?

Thank you!

Comments

Sam Moore’s picture

Did you try using "Group By" in a Views table?

steve_fister’s picture

Yes, I tried that. It didn't give the results I was looking for unfortunately..

Sam Moore’s picture

In that case I think your best bet is to alter the table at the theme layer. Have a look at @nitin.k's response below.
You might find it easier to output the View as something like an unordered list, since I've always found it kind of a pain to take tables apart programatically. Then you can assemble the table yourself in code.

steve_fister’s picture

Thanks Sam. This is where my ineptness shows, unfortunately. I don't yet understand what "Alter the query using hook_views_query_alter" means. Some googling around shows this in the context of using in custom modules. However, I don't believe I need a new module, just some new templates. I've searched for some examples, but most seem to use a field--field-my-collection.tpl.php template whereas I am creating a views-view-fields--my-course--default.tpl.php (lack of understanding /where/ the template needs to go?)

Sam Moore’s picture

It's not entirely clear whether you need to alter your query, if you can get your rows to come in with all of the info you need to build your table; but yes, that hook would be implemented in a module.
If you don't, then what you need to do is theme the Views output so that it's structured as you wish.
If you need to do some logic to your output, that's best done in your theme's template.php file. In general any PHP more complicated than "if this thing exists, render it now" should go there.
To just change the markup - say, from UL elements to TR and TD?, or changing the order of presentation - you can do that in the templates, in this case Views field or row templates.
Views itself will give you theming template suggestions - look in the admin interface in the advanced section.
If you do create a template with one of the suggested names (likely by copying one of the ones that came with Views, with the intention of changing it), it goes in your theme's Templates directory.

If you're going down this road, you may want to edit your original post and move it to the Theme Development forum (https://www.drupal.org/forum/3), where people with a deep interest in theming are more likely to be found; or perhaps the Views issue queue, especially the Support Request category (https://www.drupal.org/project/issues/views).
This particular forum is for people who are building custom modules.

steve_fister’s picture

Thanks Sam. I was able to finally get some basic templates working. The examples I referred to, and my Drupal installation didn't quite jive as to the field naming conventions. In either case, I think the templating is the way to go for my needs! Thanks for your help!

nitin.k’s picture

Below can be the ways to solve the issue

1. Alter the query using hook_views_query_alter
2. Views tpl can be created and display changes can also be modified.
3. Use hook_views_pre_render for customizations.