I have multiple KML views and for each one I need to output additional fields using a custom kml-placemark.tpl.php file. As far as I can tell I can't do this.
I've tried putting the template into my theme but Views won't recognize it.
template_preprocess_kml_placemark() doesn't seem to have a way to differentiate between my different views.
Am I missing something simple or does extra functionality need to be added to kml.module?
| Comment | File | Size | Author |
|---|---|---|---|
| #11 | template_per_view-1617016-11.patch | 15.47 KB | langworthy |
| #10 | template_per_view-1617016-10.patch | 15.47 KB | langworthy |
| #5 | kml-labels_for_other_points-1617016-5.patch | 1.12 KB | jeffschuler |
| #1 | kml-different_views-1617016-1.patch | 1.63 KB | jeffschuler |
Comments
Comment #1
jeffschulerSounds to me like two different questions here. Please correct me if I'm wrong.
I'm hearing, first of all, that a kml-placemark.tpl.php template file file in your theme is not working at all...? I just double-checked this with 6.x-2.x-dev and had no issues. (I put a copy of kml-placemark.tpl.php into my theme directory (actually just tried with the Sky theme, so I put it in templates/overrides,) edited it, cleared the cache and saw the changes in my views-exported KML.)
And secondly, that you want a different template for each view.
Check out the attached patch. I'm passing $view into template_preprocess_kml_placemark(). You can then make decisions there based on ->current_display or whatever.
I'm not sure if-and-how I'd want to incorporate this into the module, but you should be able to re-implement template_preprocess_views_view_kml() and template_preprocess_kml_placemark().
Does that get you far enough?
Comment #2
langworthy commentedOk. First problem solved. I'm not sure what I was doing wrong before but I'm able to drop
kml-placemark.tpl.phpinto my theme and it gets picked up.As for my second issue, let me clarify what my goal is. I need to add
<ExtendedData>and<Data>elements to the KML that is populated by the extra fields in the view.I'm thinking I need to add a checkbox to the options form asking if extra fields should be in
<ExtendedData>and a row style plugin that prints out labels and values properly. Right now I don't seem to have enough data in$vars['content'].Comment #3
jeffschulerYou don't have those additional fields each as
$vars['content'][$field_key]?You're using 6.x-2.x-dev, right? Seen the changes that went in via #1252348: Make remaining fields available in point?
Comment #4
langworthy commentedI have the field values but not the labels. Is there an easy way to get the labels?
Comment #5
jeffschulerWhat if we did something like this?
Comment #6
langworthy commented#5 is exactly what I need for getting the label into my custom theme. I followed that up with a new issue at #1623342: Add 'label' to $vars['content'] for theming
Now I'll see about the patch in #1 for multiple views.
Thanks so much for the help Jeff.
Comment #7
jeffschulerCool. Changing issue title to reflect re-focus.
Patch in #1 needs review.
Comment #8
langworthy commentedThe patch in #1 would result in a single template file with conditional logic checking the view name. I think the "Drupal way" is to suggest template name patters and allow for a template file per view (or display). The template file in use should appear in "Theme: Information" when editing a view. I don't currently see this.
What is the simplest way to allow for template name suggestions and a template per view or display?
Comment #9
jeffschulerThat's a way better idea. :)
Comment #10
langworthy commented- I got this working on an installation of kml.module that is running #934482: WKT support. I made the changes to
2.x-devby hand. I hope I didn't miss anything.- The options have been moved from the style plugin to the row plugin.
- I made a few small coding standards changes (whitespace and line endings) where it affected changed code. I see more that needs attention but that should probably be in another patch.
- I don't see an option for
linestringso for now I've removed it frommap_row()(function name used to bemap_rows()Comment #11
langworthy commented- Removing #934482: WKT support specific code
Comment #12
langworthy commentedNote: the patch in #11 will fail using the
patchcommand. It will work when usinggit apply.Here's why:
Git moves a file and then modifies it.
git applyis smart enough to figure this out.patchis not.I also noticed that the patch failed on the
6.x-2.x-devrelease download. It works on a git checkout of the6.x-2.xbranch.Comment #13
langworthy commented