Hello,
I would love to have the Views 2.x support, if someone tells me where I can find information about porting a plugin from Views 1.x to Views 2.x, I can help !
Thanks in advance.
--
Jean-Pierre
Answering my own questions, XML to KML (http://drupal.org/project/xmltokml) can take a feed or XML view (views_datasource, from http://drupal.org/node/307223#comment-1040887 until the main code is updated (the July 2008 release is broken with the Views2) and output it as KML (to download, could probably work as a network link/feed with permissions set correctly, I haven't gotten back to that yet)
I'm hoping to get back to this soon, sorry for the delay. The plan is to rewrite much of kml module to make it a views style plugin instead of re-implementing that functionality, so then we should be able to let it work with other modules too. The module should be much leaner when finished.
Hmmm... I looked at views2 for 3-4 hours last night. Got somewhere (see http://groups.drupal.org/node/23890) but no-where near enough. This morning decided this was going to take a long time to do properly so hard-coded a custom module solution for my D6 site.
Here's the .module file for those that are interested, it's a quick and dirty fix until views integration is working. Note the hook_load as part of named menu argument that checks the content type and only implements this menu for those node types. On our site 'node/%ride_story/tracks' is a standard view showing related nodes in a tab and works just fine. One could use node_load inside there but I believe the menu system calls that load function for each request to a matching path and didn't want to do a full load for those when checking the content type was all that was required.
/* Temporary module until views integration is done */
function track_kml_menu() {
$items['node/%ride_story/tracks/kml'] = array(
'title' => 'KML',
'type' => MENU_CALLBACK,
'page callback' => '_track_kml_generate',
'page arguments' => array(1),
'access callback' => TRUE,
);
return $items;
}
function _track_kml_generate($nid) {
/* Just load a list of nodes and pass to KML module's functions */
$sql = "SELECT n.nid, n.changed FROM {content_field_ride_database_entry} c, {node} n WHERE c.field_ride_database_entry_nid = %d AND n.nid = c.nid AND n.type = 'track' and n.status = 1 order by n.title";
$result = db_query($sql, $nid);
$nodes = array();
$max_changed = 0;
while ($node = db_fetch_object($result)) {
$nodes[] = $node;
$hash_list[] = $node->nid;
if ($node->changed > $max_changed) {
$max_changed = $node->changed;
}
}
$attributes['title'] = 'Tracks';
$attributes['description'] = "Tracks for $nid";
sort($hash_list);
$cache_name = 'kml:tracks';
$cid = $cache_name .':'. md5(join('+', $hash_list));
_kml_feed_check_cache($nodes, $attributes, $cid, $max_changed);
}
The attached module provides barebones views integration for KML. It handles lat/lon point data from CCK fields provided by Location CCK or simple text/numeric fields.
Could be extended to work with lines/polygons, allow themable style output, generate linestrings from a list of rows within the view, and in a number of other directions but I wanted to post the simple version first to get feedback.
Robert, thanks for posting that, and sorry for the delay in trying it out and giving feedback. Putting this in as a 2.x branch sounds like the best idea as it's quite a departure (and definitely a welcome one) from the original version.
Trying it out, it worked well, and I think it's ready for an initial dev release on a 2.x branch, though I did notice a couple of things I'd like to add to it to bring it back to the capabilities of the original, like:
default views to give out-of-the box behaviour - though I'm not sure how easy that will be considering we're now supporting locations from any source (no reliance on location module any more)
network links to give self-updating feeds for each view
individual node links to let users download a kml feed for a node (this would probably tie into a default view with an argument)
link back to item as part of the default theming of the kml item
structured address data with mapping from arbitrary fields (as per your current setup) to address fields
icon styling
Robert, Robin, and anyone else interested in this issue, what are your thoughts on these points?
Thanks for the review. Most of this stuff seems reasonable. I'd also add that I need to make sure grouping works (my guess is it doesn't at the moment but it's a quick fix).
In terms of default views - should we do something at admin/settings/kml that lets people pick their primary sources of geographic data and then run the defaults through hook_views_defaults_alter? This seems feasible with a limited amount of trickery.
What are the needs around icon styling? Lots of options here, how would we like this to work?
The attached patch implements the default views via the approach discussed above. At admin/settings/kml you can choose fields as data sources for geo information as well as choose the relevant content types. The default view lives at /kml.
Frankly I think this is a lot of code for not that much win....
I was taking another look at this yesterday and I agree with you Robert, adding that default view is probably overkill as it's likely to just be overridden by users anyway. As long as we explain to users how to set up their first KML feed(s), I think we should be good.
I think we may still want a settings page to let users choose their location source (e.g. lat/long fields, location module or geo module) so we can use it for non-views powered parts, like adding a link to the node to view a KML file of its location.
Is this still active? The OpenLayers project is thinking about dynamic point loading, and a KML/Views situation would be the only way to accomplish that.
Comments
Comment #1
jeanpierre commentedHello,
I would love to have the Views 2.x support, if someone tells me where I can find information about porting a plugin from Views 1.x to Views 2.x, I can help !
Thanks in advance.
--
Jean-Pierre
Comment #2
jcamfield commentedI'm interested in Views 2 functionality as well!
Comment #3
jcamfield commentedUntil this is updated; has anyone found a workaround to export a filtered (by content type?) list of locations as KML?
Comment #4
jcamfield commentedAnswering my own questions, XML to KML (http://drupal.org/project/xmltokml) can take a feed or XML view (views_datasource, from http://drupal.org/node/307223#comment-1040887 until the main code is updated (the July 2008 release is broken with the Views2) and output it as KML (to download, could probably work as a network link/feed with permissions set correctly, I haven't gotten back to that yet)
Comment #5
geodaniel commentedI'm hoping to get back to this soon, sorry for the delay. The plan is to rewrite much of kml module to make it a views style plugin instead of re-implementing that functionality, so then we should be able to let it work with other modules too. The module should be much leaner when finished.
Comment #6
milos1234 commenteddont mean to rush, but is there a new version soon?
cheers
Comment #7
geodaniel commentedI'm going to try and devote some time to kick-starting this next week.
Comment #8
milos1234 commentedcool thanks! cant wait
Comment #9
raintonr commented+1 for this... will have a crack at a patch this weekend (erm... I hope).
Comment #10
raintonr commentedTricky.
Hmmm... I looked at views2 for 3-4 hours last night. Got somewhere (see http://groups.drupal.org/node/23890) but no-where near enough. This morning decided this was going to take a long time to do properly so hard-coded a custom module solution for my D6 site.
Here's the .module file for those that are interested, it's a quick and dirty fix until views integration is working. Note the hook_load as part of named menu argument that checks the content type and only implements this menu for those node types. On our site 'node/%ride_story/tracks' is a standard view showing related nodes in a tab and works just fine. One could use
node_loadinside there but I believe the menu system calls that load function for each request to a matching path and didn't want to do a full load for those when checking the content type was all that was required.Comment #11
rsoden commentedThe attached module provides barebones views integration for KML. It handles lat/lon point data from CCK fields provided by Location CCK or simple text/numeric fields.
Could be extended to work with lines/polygons, allow themable style output, generate linestrings from a list of rows within the view, and in a number of other directions but I wanted to post the simple version first to get feedback.
Comment #12
looplog commented+ 1 for views 2 ...
Comment #13
geodaniel commentedRobert, thanks for posting that, and sorry for the delay in trying it out and giving feedback. Putting this in as a 2.x branch sounds like the best idea as it's quite a departure (and definitely a welcome one) from the original version.
Trying it out, it worked well, and I think it's ready for an initial dev release on a 2.x branch, though I did notice a couple of things I'd like to add to it to bring it back to the capabilities of the original, like:
Robert, Robin, and anyone else interested in this issue, what are your thoughts on these points?
Comment #14
geodaniel commentedI've committed this initial version to HEAD, slightly modified to include $Id$ tags.
Comment #15
rsoden commentedHi Dan,
Thanks for the review. Most of this stuff seems reasonable. I'd also add that I need to make sure grouping works (my guess is it doesn't at the moment but it's a quick fix).
In terms of default views - should we do something at admin/settings/kml that lets people pick their primary sources of geographic data and then run the defaults through hook_views_defaults_alter? This seems feasible with a limited amount of trickery.
What are the needs around icon styling? Lots of options here, how would we like this to work?
Will post patches for these requests when I can.
Cheers,
Robert
Comment #16
rsoden commentedThe attached patch implements the default views via the approach discussed above. At admin/settings/kml you can choose fields as data sources for geo information as well as choose the relevant content types. The default view lives at /kml.
Frankly I think this is a lot of code for not that much win....
Comment #17
rsoden commentedHit submit too fast.
Meant to end with I'd rather see this not committed, but am posting to give you a sense of what a default KML view feature would entail.
Comment #18
kubajs commented+ 1 for views 2 ...
Comment #19
geodaniel commentedI was taking another look at this yesterday and I agree with you Robert, adding that default view is probably overkill as it's likely to just be overridden by users anyway. As long as we explain to users how to set up their first KML feed(s), I think we should be good.
I think we may still want a settings page to let users choose their location source (e.g. lat/long fields, location module or geo module) so we can use it for non-views powered parts, like adding a link to the node to view a KML file of its location.
Comment #20
tmcw commentedIs this getting committed? The patch has been in the queue for a long time now.
Comment #21
tmcw commentedIs this still active? The OpenLayers project is thinking about dynamic point loading, and a KML/Views situation would be the only way to accomplish that.
Comment #22
jeffschulerKML 6.x-2.x-dev includes Views support.