0

I want to make an awards event where users can log in and nominate their products in specific categories.

  • I have a node: "Awards Event" where the details of the event are defined
  • I have a taxonomy: "Awards Event Categories" - these are the categories which can contain multiple nominated products. These categories will be used for multiple awards events. Within 'Awards Event' node the admin defines which of these categories will be available in this particular event.
  • I have nodes: "Products" - these are controlled by the users who'll assign them to a category

Basically what I want is a way to build a list of which products are nominated in each category within each Award Event.

Is there an easy way to accomplish this? I could just simply add a new field within the product node where the taxonomy term can be selected - but this would require me to add that new field each time an awards event is created. I'd prefer if there was a more automated way.

  • As your question is now, I'd consider it too broad and likely to be closed for this reason. Fur sure you'll have to create a kind of relationship between your events and categories. Afterwards create your view(s) which you can integrate to your event pages as blocks. If you experience any odds or got stuck on your way, feel free to edit your question providing more details of what you've done and went rogue. – Mario Steinitz Aug 13 '18 at 2:06
0

You could create a view which will display content filtered by a category, note that the category filter should be a contextual one.

In the node, you should have a taxonomy term reference field and then in preprocess, you can create your own variable by rendering the view with a contextual filter. The contextual filter in this case will be the value of the taxonomy term reference field.

This will handle the desired behavior but won't be as flexible. It will cover choosing a different term for each node, but you will be stuck to the same view.

0

It is a very common request to list entites that share the same Taxonomy terms as the page you're currently viewing. You can solve it by creating a Views Block with a Contextual filter that passess the Taxonomy term information of the current page to the Views Block for filtering.

In your case here is what you do:

Filter according to Taxonomy term of the current page

  1. Create Views of type Content that shows Product nodes and create a Block Display.
  2. Add the field that references "Awards Event Categories" Taxonomy from the Product nodes
  3. Add a new Contextual filter Has Taxonomy term ID from the Content Category and configure it with these options:
    When the filter value is NOT in the URL
    Provide default value
    Taxonomy term ID from URL
    Load default filter from node page, that's good for related taxonomy blocks
    Limit terms by vocabulary
    [Awards Event Categories]
    Multiple-value handling
    Filter to items that share any term

    When the filter value IS in the URL or a default is provided
    Specify validation criteria
    Taxonomy term ID
    [Awards Event Categories]
    Multiple arguments
    One or more IDs separated by , or +
    More
    Allow multiple values

  4. To test that the Contextual filter is working correctly you can use the Preview with contextual filters: field where you enter the term ID and see if the results below get filtered appropriately.

    If you enter 1 and press Update preview the results below will only show Products that have been tagged with the term that has TID 1 (check for your term IDs on the Vocabulary list terms page by hovering over the Operations links).

    If you enter 1+2 the results will be reduced to show only Products that have either term 1 or term 2.

    If you enter 1,2 the results will be reduced to show only Products that have both the term 1 and term 2.

    Group results by Taxonomy term ID

  5. Under your Format settings enable grouping by choosing Awards Event Categories (or whatever your field name is) under Grouping field Nr.1

  6. Edit the "Awards Event Categories" field and set Exclude from display so it's not repeated because the Grouping will render it above its batch of results (you still control the Grouping Label and output here in the Field settings)

    You now have the Views results grouped by the Taxonomy term they're tagged with, so you basically see more than one set of results, depending on how many tags there are in the results.

    Place the Block

  7. Now place the Block in a region of your theme, don't forget to adjust the Block settings for the Contextual filter, set it to only show on "Awards Event" content type.

Now when you visit an "Awards Event" node you will see the list of existing Products that share the same terms as that node, and they will be grouped in batches by each term.

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.