Closed (won't fix)
Project:
Panels
Version:
7.x-3.x-dev
Component:
Mini panels
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
1 Nov 2011 at 14:02 UTC
Updated:
25 May 2012 at 15:37 UTC
I am printing a node in a mini panel. The node has a field for image, external link (link module) and node reference field. I want to link the image to the external link field.
What would be nice here is to have a new option for the pane that says link to: node/node reference field/external link etc or use an available substitution for linking.
Any ideas how to solve this?
Comments
Comment #1
itangalo commentedI would use Views for doing this – bringing in both fields and then doing a rewrite.
I guess this could be a part of generalized formatter in Panels (or even for the image field), but I don't see how it can be made generic enough without getting something similar to Views rewrites and stuff. So I would go for Views.
Comment #2
pontus_nilssonYes Views would be a solution but it feel wrong to have to boot up Views, load the entity all over again when it's already available in the mini panel. What if Views rewrite functions were available in ctools?
Comment #3
itangalo commentedSecond best suggestion is to write a custom formatter for the image field, and somehow make it aware of token replacement patterns, or just any link fields on the same node.
Comment #4
itangalo commentedOh, HERE's another solution.
Write a CTools relation plugin, that takes a string (including token replacement patterns) and returns a new string. That would basically do Views rewrites, without the need of the full Views framework.
Comment #5
Letharion commented@Itanglo
What about moving the Views re-write functionality down the stack, making it available to Panels as well?
Comment #6
itangalo commented#5: I don't know enough about the re-write functionality to say how possible this is, but in general I am all for it. Making components of a module accessible to other modules is goood.
Comment #7
Letharion commented@merlin How feasible would it be to expose the "re-write this field"-functionality to content panes in Panels?
Adding a content "before" another, hiding it as we exclude in Views, and then getting a token in a "later" content pane? Would it have performance consequences?
One thing I don't really like, and that I feel could speak in favor of the solution in #1, is that keeping this functionality within Views keeps a nice separating between what content we generate and were we place it.
Other comments on that?
Comment #8
pontus_nilssonTo me it feels really wrong having to boot up Views in this matter. I mean everything is in place that we need and the entity is loaded. Having to load it in again in Views seems like a performance killer.
Comment #9
Letharion commentedYes, and I suppose I agree. It probably wouldn't be very good for performance at all once you do it in a few places. On the other hand, the panel could render cache the entire View.
Mostly, I completely agree with you, it's just the part about duplicating Views functionlity I don't like. :)
@merlin, Please see my question in #7 :)
Comment #10
merlinofchaos commentedIn Panels, instead of using rewriting, you use context + content types.
Data is loaded in context, output is in content types. If you need to do custom manipulation, then that should be done in the context itself, where possible. With entities and formatters I think a LOT of the things you might ordinarily do with rewriting can be accomplished this way.
You can also use custom field panes and tokens from contexts to do a lot of custom text with the tokens, especially now that field tokens are working via token.module. This is something that probably could use a little tutorial, in fact.
Comment #11
itangalo commented/me takes notes about the "tutorial" thing. It is now on my (pretty long) list.
Comment #12
pontus_nilssonHmmm... I need to try this out. Right now I don't see how I could show an image field with a specific image style and link it to an external link (link field).
Comment #13
merlinofchaos commented#12: The issue there is that there may need to be a formatter that does what you want. Right now the entity pane can do the first part of that (image field with specific image style) but I don't believe the formatters currently allow linking to arbitrary paths.
Comment #14
merlinofchaos commentedAlso, potentially a "custom" pane (in the UI) with token support enabled with something like this could do the trick:
Comment #15
Letharion commentedHow about a formatter, that allows attaching to a text field and/or link field, which takes a "field-argument".
The formatter would then get the render of the "argument", and output l($argument, $link-field, HTML => true);
I'm not entirely sure how this would work myself, so I guess I'll just have to try. :)
Comment #16
pontus_nilsson#13 Yes as you mention the ability to link to arbitary link field is missing from the formatter.
Could that be a setting that ctools can add? I mean an addition to the fields own formatter setting. I guess a new option in ctools_entity_field_content_type_formatter_options() or ctools_fields_get_field_formatter_settings_form() could add a list of all fields available in the context? I don't know enough about field formatters to know how we pass that on to rendering of the field properly.
Another idea, which also is a workaround is applying a style to the pane where the style wrapped the pane in a link. User interface wise it doesn't really makes sense to add it here though. I've made a sandbox project that demonstrates this .
Comment #17
Letharion commentedhttp://drupal.org/project/semantic_panels has been built partially to fix this. Won't be fixed in Panels.
Comment #17.0
Letharion commentedBetter description.