Heya,
I have an openlayers data overlay consisting of polygons which are drawn from KML data stored in taxonomy terms - the result being a map with polygons tied to particular taxonomy terms.
I'm creating a custom openlayers behavior to provide clickable polygons that link to the taxonomy term pages. To do this, I've added a 'tid' field on the taxonomy term OL data layer view, and I'm trying to use views_pre_render to transform that field into a full drupal url for the term, so that I can then pass that attribute into my behavior as a link.
So I'm trying to do something like this:
if ($view->current_display == ('openlayers_1') ) {
foreach ($view->result as $term) {
$term_id = $term->tid;
$term->tid = url('taxonomy/term/' . $term_id);
}
}
with the hope that I can then use feature.attributes.tid in my behavior as the full nicely transformed drupal link, so that the link will have any url aliases on the term etc as part of the link.
What I can't figure out is where to intercept the view such that I can transform this data before it reaches the openlayers behavior as an attribute object. I've tried pre_build, pre_execute, pre_render, and post_render, but no matter what I do, the feature.attributes.tid item comes in as either the original tid or a concerning '0' only.
Any tips? This is My First Behavior so I'm definitely open to other techniques here too.
Comments
Comment #1
zzolo commentedHey @elly. Well, there may be a built-in Views field to create a URL, where you could use the TID field [tid] as a replacement value.
You could also use just the TID on the JS side to create your URL with Drupal's JS API. I think it's Drupal.settings.basePath (https://drupal.org/node/114774#base_path)
Let me know how that helps.
Comment #2
zzolo commentedHey @elly. Closing for now. Re-open if needed.