The popups (or tooltips) are the place to display the data on the feature.
Sometimes you wish to display some more complex html in the popup or adding images, embed video or any field that can be added in the view display. Theming those field in the behavior JS is not very easy or trivial and it's seems that it could be done in a template file. Attached a patch for adding this template file.

CommentFileSizeAuthor
popup_tpl.patch4.32 KBkonforti
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

zzolo’s picture

Hi @konforti, thanks for the patch.

Your point is definitely valid, but the main thoughts behind the current way of doing this is:

1) Drupal provides a way to theme it in JS, albeit pretty limited and non-obvious/documented.
2) There is often a lot of data with the feature (besides just attributes) that can be used when rendering it on the OL side that could affect how someone would want to display the contents of the tooltip/popup.

I am open to a discussion on this, but I would push to keep things as they are.

strk’s picture

@konforti, you can obtain what you're after by using JS theming and ajax. Or just have your content string put in the feature attributes and use just JS theming to display it.

konforti’s picture

@zzolo & @strk thank you both for your answers,
The main goal of this patch is to have another way that avoid using JS theming and the creation of a new popup behavior.
The patch dose not cancel this approach and you can always use it for advance uses.
for common task like adding images, addresses, links etc. and theming it, you don’t need to create new behavior or to have knowledge in JS or understand OpenLayers. just grab the .tpl to your theme and change it as you like.
I think that for the most common tasks and most common developers/themers it could be a very handy way for doing it.
(and also for much more complex layouts and the use of preprocess function that help you pass almost any variable you need to the popup).
With out the elimination of any other way.

strk’s picture

Note that 'name' and 'description' attributes are common to other kind of vector layers, so by defaulting to use of a 'popup' attribute instead you break support for things like KML layers.

At the very least the JS part should apply some heuristic to figure out what's a title and what's a description, or what's already-formatted informations.

All in all I don't mind having PHP code determine how do views features attributes look like.
But again, wouldn't that be the duty of the view module itself ? As it allows to "render this field as a link to the node"
couldn't it also allow "render this field using this template" ? Sorry if I'm saying something obvious as I'm not very much
into views.

zzolo’s picture

Yeah, the idea is that most of the theming is handled by Views, and the only JS theme part is putting together that "name" and "description" fields. Also, check out #748646: Allow Views Display to render all fields in the description if you want more ability to theme.

zzolo’s picture

Status: Active » Closed (works as designed)

Closing for now. Not the worst idea since it is more of the way people would expect to theme things, but maybe just more documentation.