0

In Kickstart 2 there is a view called collection_products which displays a list of products in a given collection, grouped by category.

There is a header which uses a Block display to give anchor links to each Category Header on the page. The format of the fields is 'Unordered List' yet the fields are styled as

<div><h3><a> 

...not

<ul><li><a>

...as I would like.

How do I change the generated styling of these? I've searched all over the view and can't find it.

HEAVY EDIT. Big Thanks to J. Reynolds!

The issue is that this view is actually a list of group headings. The reason it displays as it does is that it's showing a list of all categories... each as a 'Title'...

...for each category and then a -hidden- list of the products.

So it's not that each 'row' is being themed not as a list, but that what I -thought- was a 'row' is actually a 'title'.

So: What I need to do is create an unordered list with the -title- of each category (the Grouping No. 1) as the actual li using each of these headings.

How do I do this?

BONUS: Is there a way to get Drupal to not even generate that hidden UL of products? It seems wasteful, not just for the client, but at the server.

0

It is the same as with any view: You have to override the view template.

In your views UI click on 'Theme:information'. This will open up a dialog with views templates and suggestions. As the block is using grouping, you need to override the 'Style output' theme template:

views-view-list.tpl.php

If you override that template it will override it for all views of HTML List format, so you now have to select a suggestion. Second in the list is:

views-view-list--collection-products.tpl.php

which will be fine.

enter image description here

Create a new file in your theme templates folder called

views-view-list--collection-products.tpl.php

Then click on the 'Style output' link back in the view theming information. It will open up a file and you copy everything from the

enter image description here

Now you can edit that file to get the markup you want. You can take out the h3 tag for example and replace with a div.

  • THANKS! I updated my question based on your answer. You've (partially) restored my faith in the Drupal community! I now need to know which file to copy/edit to make a UL for the group headings. – jchwebdev Sep 5 '14 at 4:05
  • You can always define your own block from scratch. The reason (I think as I do not have a commerce installation to check from) that the current block includes the products is that it will only display a category if there are actually some products in it. You should be able to duplicate that with a html list view based on the category and referencing the products, and then aggregating a filter on COUNT greater than 0. – J. Reynolds Sep 5 '14 at 7:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.