0

I have a View which lists books (nodes). They are sorted by alphabetical order (Title). Good. They are linked to taxonomies (categories). I could sort by taxonomy to group books of the similar theme together, and a second sort by title. Good.

Now the problem. My client want to list both taxonomies (categories) names and title books together, so we have the following beautiful omellete of data (imagine that the lists which are book titles beggining with prefix "-" are hidden after you click on the taxonomy they belong):

 Antologies (category)
  - Interesting antology (book) *hidden until you click Antologies*
  - More interesting antology (book) *hidden til you click Antologies*

 Book about everything the meaning of life (book) *visible*

 Cooking books (category)
   - A guide on cooking data (book) *hidden til you click Cooking books*
   - How to cook an alien (book) *hidden til you click Cooking books*
 Course of the pyramid (book) *visible*
 Decameron (book) *visible*

Nonetheless to say, I am completely at lost here. I have considered to use an extra field data to the content (node = book) to set an alias, which is the category. Then order by alias and to achieve the " - " indentation, use some hook code to identify the taxonomy.

1 Answer 1

0

I would try Views Tree.

Edited: To use Views Tree, the genres would have to be a content type and the books would the use entity reference. It will do an alphabetical list as OP asked but it's unsuitable for his requirements.

3
  • I tried this module a long time ago for other matter. I think that it displays hierarchically, but my initial problem possibly is not addressed ( I don't know how to configure it, anyway ): the mixing of taxonomy item names and content node titles in the sort-by SQL of the View. I have never seen such demands from any clients in all my life, maybe I just better quit programming.
    – Cesar
    Commented Aug 12, 2016 at 8:24
  • I came home and tried what I suggested. The genres would have to be a content type instead of taxonomy. I'm sure there's a better solution than changing your site structure to match Views Tree. Commented Aug 12, 2016 at 10:00
  • Thanks for your efforts, I think I am giving up and trying the "third" field approach. All books have this extra field, which is the title unless they belong to a taxonomy, where the extra field is the taxonomy item name. Now I order by this extra field and get the list above, ordered. To group categories I am using mymodule_views_pre_render and checking if the extra field matches a category, and adding the HTML and jQuery for the grouping effect. I guess it can be achieved via contributed modules, but getting the right combination may be a nightmare. That is the problem with Drupal itself.
    – Cesar
    Commented Aug 12, 2016 at 10:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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