Hi all,

i hope i have posted in the right section. If not please point me to where i have to look. :)

We are currently building our drupal site and are now at the point where we do look at our content type and how we can present related content. For articles what we like to have is this mockup

So on the article page we want the related content in between other fields grouped by their content type.

I have some ideas how this can be realized, but i'm fairly new to drupal and i'm sure my way isn't optimal. But since once it's done it's hard to change i thought it's best to ask for other solutions.

My solution would be:
- adding a relation between all content types
- create a file field--field_related_content--article.tpl.php in which the related content types are sorted via php.
- if we have 0 related content of a specific type nothing is shown
- if we have 1 related content of a specific type it does link directly to that node
- if we have >1 related content of a specific type a dropdown is generated when hovering above that type and a link list of the nodes shows up

problem i ran into: in the array in the tpl.php file there seems to be no value for the type of the content type which we have. So if i have 3 related tournaments and 1 related gallery i can't tell which is which (or am i missing something here?). The idea would be adding another field to the relation where the editor selects the according type manually. Which isn't ideal since he then can select a wrong type.

I'm sure others have already done something similar, but i wasn't able to find hints via the search/google. Any help is greatly appreciated.

Regards Mooff

Comments

naught101’s picture

Component: User interface » API
Status: Active » Fixed

Nope, you're missing nothing. Relation only stores the entity type (eg. node, user, file), and the entity ID (numeric). It doesn't store the entity bundle (e.g. content type [page, article, etc.]). To get the bundle, you'll have to load the entity itself. You're going to have to do that anyway to get the URL, so there should be no significant performance hit.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.