I saw this was marked @todo in leaflet_views and figured it couldn't be too hard. Here's a patch. It does add Entity API as a dependency.

CommentFileSizeAuthor
leaflet_entity-view-modes.patch7.58 KBjoelrosen

Comments

pvhee’s picture

Status: Needs review » Needs work

Nice work, exactly what is needed.

We'd probably need to work out an upgrade path or at least provide some sort of warning, since existing views using display modes will render with plenty of errors and you'd need to enable Entity API as well (which makes sense).

I had some issues with rendering the full node display in JS (line 11 of leaflet.drupal.js). This probably doesn't come from the code, but maybe we should clean the output to make it safe to render in the popup?

TypeError: container is null

if (container._leaflet) {
joelrosen’s picture

By any chance does the full node display you were trying to render contain a field rendered as a Leaflet Map? That would cause this error: http://drupal.org/node/1796656, which would explain things.

I don't really agree that the module should concern itself with cleaning rendered node output. I'm not having any problems using teaser view modes, and I think if the user really needs to do some special processing to their rendered entity output, they can implement template_preprocess_entity or something.

So, for an upgrade path, I guess the answer is to implement hook_update_N to 1) make sure Entity API is enabled and 2) search for any saved Views displays and replace the options for the old view modes with #rendered_entity, ya? Do you know what number I should use for N here? I guess it depends on what stable version you plan introducing this to... not really sure how that works.

pvhee’s picture

Title: Support view modes for any entity type » Support view modes for any entity type - add upgrade path

Yes, you're right. The "full" view mode contained a geofield formatted with the Leaflet map, which breaks the rendering of the map. Removing that field from the display fixed things.

I've committed your patch, and I've added leaflet_views_update_7000 in leaflet_views.install, so you need to add entity api before upgrading.

We should still find a way to have the views converted, so leaving this issue open.

levelos’s picture

Issue summary: View changes
Status: Needs work » Closed (fixed)

Closing, it's been a year.