1

My problem is not technical but structural.

The idea is that users can submit an ad (to sell a car for instance) with entityForm, or webform.

To define the car to sell, I want a predefined list to avoid misspelled words.

The first solution I tested was to use Taxonomy like that:

-Audi
--A1
--A3
--A4
-Seat
--Ibiza
--Leon

I used "Hierarchical Select" and then "Simple Hierarchical Select" and even "Term Reference Tree" but my problem is still the same.

When I want to use a view to display the EntityForm Submissions, it shows the car in one column like that:

Car


.Audi
..A1


.Audi
..A3

And I want it on 2 columns like that:

Brand | Model


Audi | A1
Audi | A3

Does taxonomy allow that and how?

Should I use a database table with another module?

Thanks for any help!

1 Answer 1

0

You don't need any changes to your database, with HS Or SHS you already store enough data to built a template answering your needs.

From my point of view, once your view is configured, you can alter the display of your field while overriding the default TPL file.

From the view edit page, if you go into "Theme: Information", you can find the name of the file you need to create and place into your theme folder.

The file name should look like this:

views-view-field--name-of-your-view--name-of-your-field.tpl.php

As a base for you file, you should use views-view-field.tpl.php (located in sites/all/modules/views/theme). In that template, there's some variables available to help you build what you want (like $row or $field).

If you have Hierarchical Select installed, you can simply render the field, it will display data the way you want.

Here's some untested code:

$field = field_view_field('entity_name', $fully_loaded_entity, 'your_field_name'); 
print render($field);

For that chunck of code to work, you need to specify if you're working with a node, user or term, pass the loaded entity and give the corresponding field name.

The rendered HTML should be enough to build something like this (made with the exact same method):

HS rendered field

1

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.