Currently in the Views Display, you can only choose a field to be displayed as the "description" which can be used as the body of popup. There should be another option to render out the fields like in a normal view. This is currently a feature in the 1.x branch. I think it is very useful if you want to just include a few fields, as well as being able to leverage more Views theming.

Files: 
CommentFileSizeAuthor
#53 allow-views-display-to-render-all-fields-in-the-description.patch7.39 KBjvizcarrondo
Test request sent.
[ View ]
#48 allow-views-display-to-render-all-fields-in-the-description-748646-48.patch4.43 KBmongolito404
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch allow-views-display-to-render-all-fields-in-the-description-748646-48.patch. This may be a -p0 (old style) patch, which is no longer supported by the testbots.
[ View ]
#41 allow-views-display-to-render-all-fields-in-the-description-748646-41.patch3.83 KBollynevard
Test request sent.
[ View ]
#32 20100826-view-export.txt4.53 KBdavidhk
#31 openlayers_map_export.txt5.62 KBBWPanda
#28 Views-preview.jpg78.14 KBdavidhk
#28 popup.jpg111.78 KBdavidhk
#25 748646-24.patch2.68 KBdavidhk
Test request sent.
Previous result: FAILED: [[SimpleTest]]: [MySQL] Invalid patch format in 748646-24_0.patch.
[ View ]
#24 748646-24.patch2.68 KBdavidhk
FAILED: [[SimpleTest]]: [MySQL] Invalid patch format in 748646-24.patch.
[ View ]
#17 patch-748646-13.patch3.75 KBdavidhk
FAILED: [[SimpleTest]]: [MySQL] Invalid patch format in patch-748646-13.patch.
[ View ]
#13 patch-748646-13a.patch582 bytesdavidhk
FAILED: [[SimpleTest]]: [MySQL] Invalid patch format in patch-748646-13a.patch.
[ View ]
#13 patch-748646-13b.patch566 bytesdavidhk
FAILED: [[SimpleTest]]: [MySQL] Invalid patch format in patch-748646-13b.patch.
[ View ]
#13 patch-748646-13c.patch584 bytesdavidhk
FAILED: [[SimpleTest]]: [MySQL] Invalid patch format in patch-748646-13c.patch.
[ View ]
#13 patch-748646-13d.patch2.06 KBdavidhk
FAILED: [[SimpleTest]]: [MySQL] Invalid patch format in patch-748646-13d.patch.
[ View ]

Comments

Assigned:Unassigned» zzolo

Given that this is now a theme function, I don't think that this is necessary. Do you?

I would say its still open. The theme function is for the grouping, which renders a bunch of outputs together in the same popup or tooltip.

The need here is for our plugin to render the fields of a view like it normally would. For instance, if you wanted to have a title and an image in the popup, this is not currently possible without some sort of composite field. This should just be a matter of porting this functionality from 1.x. I plan on using my sprinting time next week at DrupalCon towards OpenLayers (with phayes), so I should be able to address this (and more) this weekend and next week.

Pending this functionality, how would I go about theming the popup content? Where should I start looking?
Thanks!

I looked into this one a few days ago and ran into a bit of a stumbling point because the views display plugin is not using row plugins (actually the style plugin needs to be designated) and after about an hour of trying to make work, I out it off. It seems fairly straightforward of changing the switch to TRUE but for some reason that was not fully working for me. I'll have to put more time into it.

As far as theming, in theory, you should be able to use the regular views themeing functions.

It looks like I can't theme the field that is used for "description" in the popup with a views-view-field.tpl.php file, as openlayers is using a raw value from the views row. Is there any other way/approach?
Thanks.

[Edit]: views-view-field.tpl.php instead of views-view.tpl.php

I thought you were referring to this ticket and the changes that will be made here.

If you want to theme the current output, you can use:
For non-grouped data, you should be able to theme the field
For grouped data, there is currently an issue: #736576: Use theme function instead of hard-coded markup in grouped Views display plugin

Sorry, you are right, I should have opened a new issue: #787026: Allow non-grouped views output to be themed with Views

I have this working so that the contents of the popup comes from the views rows plugin, but I need some help on how to fit it in with the current design.

Currently there's no way for the admin to choose which row plugin he wants to use. The problem is that the display plugin and style plugin both have

'type' => 'openlayers',

So when views builds its list of row plugins to choose from, it looks for plugins with a type of 'openlayers', and of course there aren't any. The ones we are most likely to use (Fields, Node) have type 'normal'.

There are a couple of workarounds I can think of, but neither are very user-friendly:
- fix the default row plugin to be 'fields'. The user can configure its settings, they just can't change to another row plugin.
- Use the Default display to change the row plugin, which will then change it for the OpenLayers Data display

An alternative is to change the type of the display and style to 'normal'. That would give the admin access to more row plugins, and give the admin a more typical views experience. The downside is that the Openlayers Data style plugin would then be available to all displays, whereas currently it only shows up if you're editing an OpenLayers Data display.

What do the module developers recommend?

Just a side note: even if the rendering is completely handled by the plugin itself the fields are processed and themed as usual.

You can test this by commenting (disclaimer: dirty trick here) unset($options['analyze-theme']); at the end of openlayers_views_plugin_display_openlayers.inc

Then you will see the available templates in the view UI; if you pick and change the field template adding a dpm($field) (or dsm($output) if you don't have enough memory) you'll notice that the template is called as usual.

Moreover if you replace the line where the feature item is set (around line 360 in openlayers_views_style_data.inc)

<?php
- $feature['attributes']['description'] = $rendered_record[$description_field];
+
$feature['attributes']['description'] = $this->view->style_plugin->rendered_fields[$id][$data_source['description_field']];
?>

you'll be able to use the themed value (given that you modify the appropriate template field file).

+1 for the first option suggested by gwulo (fix the default row plugin to be 'fields').

Thanks Emanuele. I'm still finding my way around Views, so your comments are very helpful.

I'll post up the changes as a patch later this week, and will be grateful for your feedback.

Regards, David

The theme function is for the grouping, which renders a bunch of outputs together in the same popup or tooltip.

I've been hunting around for this exact functionality. Which theme function are you guys referring to here?

(apologies, I know this doesn't relate to the issue topic)

Status:Active» Needs review
StatusFileSize
new2.06 KB
FAILED: [[SimpleTest]]: [MySQL] Invalid patch format in patch-748646-13d.patch.
[ View ]
new584 bytes
FAILED: [[SimpleTest]]: [MySQL] Invalid patch format in patch-748646-13c.patch.
[ View ]
new566 bytes
FAILED: [[SimpleTest]]: [MySQL] Invalid patch format in patch-748646-13b.patch.
[ View ]
new582 bytes
FAILED: [[SimpleTest]]: [MySQL] Invalid patch format in patch-748646-13a.patch.
[ View ]

Here's the patch. It's a little different from the issue title - it uses the views row to build the full contents of the popup, not just the description.

To see a demo, try http://gwulo.com/OL_demo. The view has fields title, lat, lon, and two dates. The lat & lon are excluded from display. The dates are set to display inline with ' - ' as separator. So the popup is built just using standard views functionality.

After installing the patch, existing views and popups continue to work as before. BUT, the OpenLayers Data display shows an error "Row Style: Missing Style Plugin", and doesn't get any of the new functionality from this patch. The only way I can see around this is to edit the view to remove then re-create the OpenLayers Data display.

When you create a new OpenLayers Data display, there's a new option on the OpenLayers Data style plugin. It lets the views admin choose whether the popup content is built from Title & Description (ie the current way), or from the Views row.

The popup's content is all built in the view now, so the javascript behaviour just displays whatever it is given, without any changes or additions.

Hi @gwulo, thanks for the patch(es). I am still trying to catch up on emails and tasks, but hopefully will have time to review this soon. I am really interested in getting this in as it is a much needed function that was not ported from 1.x. What's with the multiple patches by the way?

I used Winmerge to make the patches - it makes one patch file for every two files I compare.

Is there a better way - eg should I cut & paste them into one file?

This isn't my day job, so lots to learn!

This should be helpful: http://drupal.org/patch/create

StatusFileSize
new3.75 KB
FAILED: [[SimpleTest]]: [MySQL] Invalid patch format in patch-748646-13.patch.
[ View ]

Here's the patch again, with the changes in a single file.

Subscribe.

@gwulo, thanks for the patch and sorry for the delay in response. Basic look at patch seems ok. The one thing I would suggest is not to do the option of choosing between fields and rows, but to just have drop down for description to have an option. Will test soon.

An option in the description drop-down would work too. I'm off on summer vacation for a couple of weeks, but will have a look at it when I get back - if noone beats me to it!

Regards, David

Status:Needs review» Needs work

Patch applies, but doesn't seem to be working - I can see the new setting for displaying the view row in the popup, but when I select it and save, the map popups are empty...

@BWPanda, sorry to hear that. The only things I can suggest you've probably tried already - clear the browser cache and drupal cache, and make sure that in views there are some fields selected for display.

I'll have some time next week to make the change suggested in #19, and will test the current patch against the latest dev build then.

If I dsm() the value of $feature['attributes']['popup_content'] at the end of the patch in the if() statement, I get the following:

<div class='openlayers-popup'>
  <div class="views-field-field-lifegroup-type-value">
                <span class="field-content"></span>
  </div>
  <div class="views-field-field-lifegroup-leader-value">
                <span class="field-content"></span>
  </div>
  <div class="views-field-field-lifegroup-address-value">
                <span class="field-content"></span>
  </div>
  <div class="views-field-field-lifegroup-town-value">
                <span class="field-content"></span>
  </div>
</div>

So it can see each of the fields, just not the values in them...
And it was working when I just assigned one field to the title and description before I applied your patch, so the view is setup correctly.

Another thing to note, I just tried changing 'In popup, show:' to 'Title and Description', but the popups are still empty and my dsm() output from above still shows (which is only present in the 'if' part, not the 'else' part)...

Status:Needs work» Needs review
StatusFileSize
new2.68 KB
FAILED: [[SimpleTest]]: [MySQL] Invalid patch format in 748646-24.patch.
[ View ]

@zzolo, here's the revised patch based on your comment in #19. It's a smaller change than the previous one, so thanks for the suggestion.

@BWPanda, I'm not sure what's causing the problem. It's not a big change to the code, and just uses the standard Views row rendering to build the content.

I'd certainly recommend trying a new view to see if that makes any difference. The steps I followed were to first build as simple a view as possible. Just add filters, and fields to display. At that point the Live Preview should show the fields for 10 records. Check that each record shows something! (In testing I confused myself at one point where I had some old records with no data in the fields I used for popups, and couldn't understand why I had blank pop-ups).

Then add & configure the OpenLayers Data and OpenLayers Map. On the OpenLayers Data config screen, choose Style Options and set 'Description Field:' to . You should get a map with 10 markers, and each pop-up shows the same information that was displayed in the Live Preview for its record.

StatusFileSize
new2.68 KB
Test request sent.
Previous result: FAILED: [[SimpleTest]]: [MySQL] Invalid patch format in 748646-24_0.patch.
[ View ]

Try again, with correct filename: 748646-24.patch

Status:Needs review» Needs work

I'd love to mark this as RTBC, but it's still not working for me...

I installed a brand new copy of OL 2.x-dev on my test site, applied the patch, then created some nodes with location data and a view to match.
When setting a single field to either the title or description (or both), the popups display correctly. But when I set the description to '<all> (render entire row)', nothing's displayed in the popup (unless of course I've also set a title, which displays but not the description).

As far as I can tell, it seems the issue lies with $this->row_plugin->render($record). As above, it outputs the HTML, but without any values in it... I've looked through the code to see if I could work out what it should be instead, but I don't know enough about Views to figure it out.

StatusFileSize
new111.78 KB
new78.14 KB

@BWPanda, if you : edit your view, click the 'OpenLayers Data' tab, then click the 'Preview' button at the bottom of the screen, do you see all the fields displayed as you expect to find them in the pop-up?

If you look at the attachment Views-preview.jpg, you can see how it looks here. Then popup.jpg shows how the same fields appear in the popup.

If that doesn't help, I'm not sure what to try next. It would help if someone else could also try the patch, to get another data point.

gwulo, you can't preview map data, as you get the message: "OpenLayers views are not compatible with live preview" when you try... That's all I see when I preview my map view (both the data display and the page display).

My mistake, I was forgetting about the little drop-down to the left of the preview button.

So the Views-preview.jpg on #28 is for my "Defaults" display. What do you see if you preview the Defaults display?

A bit more background in case we use different steps to build our views. On my test View I've got three displays listed:
- Defaults
- OpenLayers Data
- Page (which is really the OpenLayers map)

Both Defaults and OpenLayers Data show "Row Style: Fields", and all the fields in the "OpenLayers Data" display show "Status: using default values.".

So as I understand it whatever shows up on the "Defaults" display's preview should be what Views generates when we call render to build the content for the popup.

StatusFileSize
new5.62 KB

Let's go one better: attached is an export of my map view.

My Defaults display preview shows the same message as my OpenLayers Data one (because I setup the OpenLayers Data display without overriding default values), but I also have an Attachment display setup to show the same info as the OpenLayers Data one for testing purposes - it shows the following on preview:

GEOMETRYCOLLECTION(POINT(152.92968749389 -30.448673678186))
test1
lalala
GEOMETRYCOLLECTION(POINT(146.95312499413 -42.032974331065))
test2
blah blah
GEOMETRYCOLLECTION(POINT(142.38281249432 -11.911940510561))
test3
yada yada yada

Hope that helps figure this out.

StatusFileSize
new4.53 KB

I've built a view the way you described, but the pop-ups still display their contents ok (export attached).

I notice I'm running an old version of views, 2.6. Which version are you using?

Otherwise, these are the only differences I can see between our exports:

Defaults
- Fields: GL uses Latitude / Longitude / Title. BWP uses WKT / Title / Body
- Items per page: GL use default 10. BWP set to 0

OpenLayers Data
- Data Source: GL uses lat/lon, BWP uses WKT

Page
- Attachment display: GL doesn't use, BWP uses
- Menus: GL doesn't use, BWP defines a menu item

I haven't tested the patch but the 1-line change in #10 is exactly what I was looking for. It allows for a tpl file and corresponding preprocess function to affect the description field before it goes into the popup. In my case I was needing to load the rendered node teaser into the popup and this is the only way I've found to do it in OL 2.x.

Status:Needs work» Needs review

#25: 748646-24.patch queued for re-testing.

Status:Needs review» Needs work

The last submitted patch, 748646-24.patch, failed testing.

Getting there, I think. I ran in the following problem:

Style OpenLayers Data requires a row style but the row plugin is invalid.

So, basically, the display now can use row plugins but none have been defined to work with it? So, there are no row plugins to pick from.

Also, upgrade path needs to be thoroughly tested here, as I have feeling this will cause soem problems in Views.

Thanks for taking a look at this.

There are definitely problems with an upgrade path. See notes in #13:
---
After installing the patch, existing views and popups continue to work as before. BUT, the OpenLayers Data display shows an error "Row Style: Missing Style Plugin", and doesn't get any of the new functionality from this patch. The only way I can see around this is to edit the view to remove then re-create the OpenLayers Data display.
---
I don't know if there's any better way around this.

See also the notes in #9.

subscribing

Status:Needs work» Needs review

#25: 748646-24.patch queued for re-testing.

+1 Subscribe

Patch #25 didn't work for me. Nothing gets rendered in the popup description.

The views row index ($this->view->row_index) never gets set for non-grouped displays so when $this->row_plugin->render($record) gets called views doesn't know which row to render.

I've re-rolled the patch from #25 against 6.x-2.x with a fix for setting the row index. Now openlayers views will correctly render all fields in the popup description when <all> (render entire row) is selected for the description in the style options.

I've not submitted a patch to Drupal before as someone else has always beaten me to it. I followed the instructions here, hopefully it is correct?

listening

I tried the #41 patch and I can see the option in views but I'm getting this error after I update the field and after saving the views:

Style OpenLayers Data requires a row style but the row plugin is invalid.

The popups don't include any additional fields.

subscribing

Version:6.x-2.x-dev» 7.x-2.x-dev
Component:OpenLayers Views» OL API
Priority:Normal» Minor
Status:Needs review» Needs work

Patches for 6.x welcome, but any development will be focused on D7.

subscribing

subscribing

StatusFileSize
new4.43 KB
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch allow-views-display-to-render-all-fields-in-the-description-748646-48.patch. This may be a -p0 (old style) patch, which is no longer supported by the testbots.
[ View ]

Here is a re-roll of the patch in #41 for the 7.x-2.x branch. I changed #all_fields to #row, it made more senses to me. I've also added an exception in openlayers_views_style_data::map_features to keep fields excluded from display as map features when they are used as data source fields. This allow, for instance, the title, latitude and longitude fields to be used as data source but not rendered in the description.

Status:Needs work» Needs review

Status:Needs review» Fixed

Thanks for everyone's work on this. Committed:
http://drupalcode.org/project/openlayers.git/commit/effadd4

Hi,

Just wondering if this will be backported to 6.x-2.x?

Thanks,

Eve

Hi @nyleve101. I would love to, but my time is pretty limited these days, and I am pretty much the only one working on this project at the moment. Patches are welcome.

Version:7.x-2.x-dev» 6.x-2.0-beta1
Component:OL API» OL Views
Status:Fixed» Patch (to be ported)
StatusFileSize
new7.39 KB
Test request sent.
[ View ]

I have developed a solution to enable all field as row style in views, new module allows you to hide fields and all operations fields on row style in views (in this case, display openlayers data). This work was done on the openlayers version 6.x-2.0-beta1 (I am including the patch) by request of Evelyn (@nyleve101) and is now working satisfactorily. I hope it helps for someone, can be improved or to be included in a future.
Juan

Version:6.x-2.0-beta1» 6.x-2.x-dev
Assigned:zzolo» Unassigned
Status:Patch (to be ported)» Needs review

Thanks @jvizcarrondo. Can @nyleve10 or someone else confirm that this works.

Yup, it works perfectly!

Status:Needs review» Needs work

Is it possible to have a reroll of this patch ?