Problem:
I created a View (to be used as data source for Open Layers) containing a "Rendered entity" field (taken care of by Views handler entity_views_handler_field_entity).
In the options pane for this field i selected "Show complete entity" as "Display" setting.
A select list of view modes appeared, and I selected "Teaser" view mode, since that's the one I needed.
Upon rendering of the View output, my "Rendered entity" field had a link wrapped around it, linking to the node detail page.
This is not the intended behaviour.
Solution (?):
After some debugging, I found out this was caused by the code '#dependency' => array('edit-options-display' => array('label', 'id')),
for the link_to_entity Form API entry in entity_views_handler_field_entity.inc
Upon removing this line, the checkbox "Link to entity" was shown in all circumstances. In that case I could uncheck it, and everything worked as needed.
Comment | File | Size | Author |
---|---|---|---|
#20 | Screenshot from 2013-03-27 13:58:36.png | 24.24 KB | OnkelTem |
#20 | Screenshot from 2013-03-27 13:58:44.png | 9.08 KB | OnkelTem |
#20 | Screenshot from 2013-03-27 13:58:09.png | 7.94 KB | OnkelTem |
#20 | Screenshot from 2013-03-27 14:00:02.png | 9.24 KB | OnkelTem |
#19 | entity-1546776-19.patch | 1.44 KB | OnkelTem |
Comments
Comment #1
svendecabooterBelow a patch that solves this issue.
Not sure if this has unintended side consequences or not.
Comment #2
fmizzell CreditAttribution: fmizzell commentedYep, that is exactly what I did. Giving a more general title so people that have not debugged the problem might not have too :)
Comment #3
fagoYep, but the dependecy is right. We just have to ensure the value of it is FALSE in case the dependency is not met, i.e. let's implement this logic when the settings form is submitted.
Comment #4
fmizzell CreditAttribution: fmizzell commentedIf that is the way you think it should work, that is fine, but I do see some value on being able to wrap the whole entity on a link if desired
Comment #5
Anonymous (not verified) CreditAttribution: Anonymous commentedCan you just unhide the setting please? I have a similar case where I only want to be able to disable or enable the linking.
thanks in advance,
Thomas
Comment #6
markhalliwell#1 works perfectly! This took me HOURS to track down! Thought it was an annoying bug with DS or QuickTabs..... please, please commit this or figure out how you want to implement this per #3!
Comment #7
drclaw CreditAttribution: drclaw commentedMay I suggest that instead of changing the value of the "Link to Entity" field on submit, we just skip the link rendering in render_entity_link()? Patch attached.
Comment #8
OnkelTem CreditAttribution: OnkelTem commented@fago
Let me not agree with you. IMHO, dependency is not right because in this case we can't make a rendered entity to be a link. Also, we can't rely on what elements rendered entity will include.
For example, Display Suite's 'Reset' layout doesn't include any elements at all and simply concatenates field values, which can be, in their turn - inline elements.
Patch in #1 is just what is needed in this case. Setting it to RTBC. Please submit it.
Comment #9
omerida CreditAttribution: omerida commentedPatch in #7 fixes it for me. If you're rendering an entity, you should choose how/if to link to it in the display mode.
Comment #10
OnkelTem CreditAttribution: OnkelTem commentedBUMP.
Please commit the patch from #1
Comment #11
fago#7 makes sense to me - committed, thanks!
Comment #12
OnkelTem CreditAttribution: OnkelTem commentedThe fix makes it IMPOSSIBLE to make a rendered entity - a link.
Comment #13
fagoThis should be impossible - the rendered entity most likely contains links itself (as well as quite some block elements...).
Comment #14
OnkelTem CreditAttribution: OnkelTem commentedPlease read #8 where I explained why this is not true. Entity could be anything, including set of inline concatenated fields. And this is not a theory, I'm talking about real sites and real situations, Wolfgang.
Comment #15
fagostill, it was never intended to work that way and will create troubles in most cases - that is what I want to avoid. I dislike having options that mostly don't work.
I'm sry if that makes your use-case harder, but maybe there is another easy way to do it still, e.g. just link it from the entity's template? Or maybe there is something else we can do for it? Please open a feature request for discussing on how to implement it best.
Comment #16
OnkelTem CreditAttribution: OnkelTem commentedWell I personally didn't have any mentioned troubles and even don't see a reason for them.
Not a single one I can think about atm.
Even when using Display Suite there is no UI-way (without creating custom fields and typing code) to just combine fields into a link.
While with #1 and Views - this works out of the box: you add rendered entity (as a set of concatenated fields) and make it a link.
To my mind, best - is what is done by #1 - i.e. no assumptions about entity.
Comment #18
OnkelTem CreditAttribution: OnkelTem commentedYet I don't agree with the resolution and I insist on thinking again about this.
I've got one more website where I have to use patch from #1 to get things working.
Test case:
<a>term_name</a>
. Instead it uses fields like<a><span class="name">term_name</span> <span class="icon">term_image_field_1</span> <span class="description">term_text_field_2</span></a>
- i.e. to print term with it's associated image for example.Another example.
Imagine we need to list entities of different bundles in a view. Let's put that each has it's own way to represent itself. We don't even need to use Entity Label to represent entity. It could be ANYTHING. Let's call it "Inline representation of an entity", ok?
This is achieved by implementing templates for each entity bundle — via Display Suite or not — for a specific view mode.
So a view has no idea about their differences, it just print rendered entities in this view mode.
Now imagine we have two views — one is used by Entity Reference for drop-down list to set references (and we need no links), and another — to print the same list on the entity page, but now — with links.
The idea is straightforwad: in the former — not use links, in the latter — use links. Both using same "rendered entity" in the same view mode.
Need more examples?
Comment #19
OnkelTem CreditAttribution: OnkelTem commentedProviding a patch which cancels #7 and applies #1. With it you can make inline rendered entity a link in views fields.
Comment #20
OnkelTem CreditAttribution: OnkelTem commentedSome images for demonstration entities linking.
View configuration (Added Rendered Node field):
Settings of the field (note — Inline view mode and Link checkbox):
Rendered view:
Entity template configuration, using "code field" of DS module (this is just a quick example):