1

I have a View of products (nodes). They have taxonomy associated, and I am displaying the taxonomy first and ordering by taxonomy ascending. However, I would like to have all with taxonomy ordered first, but I find that the View shows first those without taxonomy, and later those with taxonomy, in this case in the correct order. How could I indicate the View that it must reserve those without taxonomy for the last, i. e.

 A Taxonomy
   - Product 1
   - Product 2
 B Taxonomy
   - Product 3
   - Product 4
 ...
 Z Taxonomy
  - Product 5

  -- Products with No taxonomy -- (this message does not display, it is only for clarification here)
  - Product 6
  - Product 7

...

4

My suggestion is to modify your main view to list only Product nodes with a taxonomy term selected, then use an attachment to your main view that lists Product nodes with no taxonomy term. The attachment would be displayed after your main view.

Steps

1. Filter your main view to list only Product nodes with a taxonomy term value

In your main view's configuration, under Filter Criteria, add a filter for your taxonomy term field (choose either dropdown or autocomplete), and select "Is not empty (NOT NULL)".

Filter by not empty

2. Create the attachment that lists Product nodes with no taxonomy term value

Add an Attachment display to your view.

Add attachment display

Under Attachment settings, set Attach to to your main view display (in this example the main view is Page), and set the Attachment position to After.

Attachment settings

In the attachment display's Filter Criteria, change the taxonomy term filter to "Is empty (NULL)". Make sure to override this setting for the attachment display only or it will apply to the main view as well.

Filter by empty

Note about the attachment header

Your attachment view will be displayed right after your main view, so you may want to add a Header to the attachment (make sure to override to the attachment display only).

Text area header

In this example I used a Text area.

Header settings for the attachment

Alternatively, you could add a label to the taxonomy term field. Make sure to override this setting for the attachment display only or it will apply back to the main view.

Label settings

Results

Your main view should now list your Product nodes by taxonomy term in ascending order, and your Product nodes with no value selected for the taxonomy at the bottom of the list.

Results

  • Thank you very much, this is way more elegant that the two ideas I had in mind: modifying the SQL query adding the NULL condition or creating a new vocabulary which would be opposite of the main taxonomy vocabulary, to group those without taxonomy and order by those two fields. Elegant solution, yours. – Cesar Aug 12 '16 at 5:12
  • You're quite welcome! Modifying the SQL was a thought I had as well. Thank you for the kind words! – Kristin Aug 12 '16 at 12:33

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.