0

I am new to drupal, but have decent knowledge of WordPress & PHP. I am currently building a drupal site where I need to link two content types together and display them on the front end accordingly.

I have one content type called Vehicle Range, which contains a list of Vehicle ranged (e.g. BMW 1 Series, BMW 3 Series)

I have another content type called Vehicle Models, which lists the vehicle models (e.g. 1 Series 118i, 1 Series 118d, 3 Series 335d).

What I want to achieve is a menu that lists all of the Vehicle Ranges with the relevant models as dropdowns.

Example:

1 Series           3 Series

   118i                335d

   118d

I have created a reference between the two content types using the Entity Reference Module. The reference field is attached to the Range content type so that you tick all of the relevant models that belong to that range.

I am trying to create a view using this relationship, but my lack of experience with Drupal and views is causing me to fail. Whilst creating a view, the closest I can get is either a list of all of the models, displaying all of their fields, but they are not 'categorised' under the relevant range, or a list of the ranges with the model labels, which is close, but I need the full content / all of the fields attached to each model rather than just the label.

How can I make a view that will give me the output I need as shown in the example above using the two content types and reference field? Any help would be massively appreciated as I'm brand new to Drupal!

1
  • It's a little tricky to give directions without seeing this particular case on my screen, but under advanced options you can find and enable "aggregation", which will give you the option to group results by, for example, range. The alternative approach is to use EFQs, which will use Drupal DB-abstraction, but allow you to do the logic in code instead. This might be easier for you if you're used to PHP but not Views.
    – Letharion
    Commented Oct 15, 2014 at 13:33

3 Answers 3

1

I don't think you need to create content types to do what you need.

You have a content type of car and then I would use taxonomy to select the series and models. You can add fields/images etc to taxonomy and pull those into your view if you need to.

1
  • Hey, thanks for your answer. Yes I was thinking that too. I will be using the models and ranges throughout the site quite dynamically and was advised to set it up using relationships, but the taxonomy set is my fall back incase I can't get this to work
    – RoseCoder
    Commented Oct 15, 2014 at 15:00
0

To do a such thing you should change elements in the "Format" section of you view like this : - Format : Unformatted list (this will display each element into a DIV) - Show : Rendered entity +

Doing this will display each result as a node based on view_mode. In the "Content Type > Manage Display" you should enable a new view_mode or use "Teaser" which is usually enabled. Like this you'll be able to select each field + formatted you want to display.

1
  • Hey, thanks for your answer. I have my format set to Unformatted list, but whenever I select Show -> Rendered entity -> select relationship -> full content, I get no results regardless of whether I select full content or teaser. The only way I can get results is if I choose show->content->select relationship->display full content which gives me the models, but not grouped under the relevant range. The relationship I am using is Referenced Entity if that helps!
    – RoseCoder
    Commented Oct 15, 2014 at 14:59
0

Resolved. Incase anybody want's to know, I set up a 'Referenced Entity' type relationship and took the following steps:

Under format, I selected 'HTML List' and under format settings, I set 'Grouping field Nr.1' to content:title and ticked the box that say's 'Use rendered output to group rows'.

Under show, i selected Fields, and added the fields from my model content type, and it worked perfectly.

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.