Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
hi,
i want to put custom field value as externalgraphic path
${field_term_image} output: 'http://localhost/auto/sites/default/files/uploads/terms/directory/gazsta...',
but in map is printed as:
<image id="OpenLayers.Geometry.Point_54" cx="389.9928530314937" cy="155.7978231292218" r="1" x="385" y="151" width="10" height="10" href="http://localhost/auto/%24%7Bfield_term_image%7D" style="opacity: 1" fill="#FFCC66" fill-opacity="0.5" stroke="#FF9933" stroke-opacity="1" stroke-width="4" stroke-linecap="round" stroke-linejoin="round" stroke-dasharray="none" cursor="pointer"/>
why?
Comments
Comment #1
zzolo CreditAttribution: zzolo commentedNot entirely sure how you set it up, but you may have to use the rendered version, and ensure you are using the URL formatter (assuming this is an imagefield).
Comment #2
dgastudio CreditAttribution: dgastudio commentedHi! zzolo!
look, i'm using image_url_formatter module to output image field as path, so, in my view i have:
${title_rendered}
${title}
${latitude_rendered}
${latitude}
${longitude_rendered}
${longitude}
${field_term_image_rendered}
${field_term_image}
${name}
where
'field_term_image_rendered' => 'http://localhost/auto/sites/default/files/uploads/terms/directory/gazsta...'.
now, i want to use this value in /admin/structure/openlayers/styles/default/edit "externalGraphic" field. so i put ${field_term_image} as value in it.
but after save, and open my map, the external graphic path is rendered as:
so u can see, the path to the image is broken.
P.D. sorry for my english
Comment #3
zzolo CreditAttribution: zzolo commentedHave you updated to latest version of 7.x-2.x?
Comment #4
dgastudio CreditAttribution: dgastudio commentedyes, last dev version from yesterday.
Comment #5
nod_It should be working by now, if not try #1364778: openlayers_style_path() must not use url() to create file paths..
Comment #6
nod_Comment #8
AndyF CreditAttribution: AndyF commentedHi,
I think I'm having the same problem. I have a taxonomy term with an image field. I set up the view appropriately, and the preview gives the token
${field_service_type_marker}
which evaluates to the full path to the image. I try to use this in a custom style as the externalGraphic, and on the map the actual path used has the hostname doubled up (eg.http://example.com/http://example.com/sites/default/files/marker.png
). The problem seems to originate inopenlayers_render_style()
where I think it tries to ensure there's a full path before doing the token substitution (resulting inhttp://example.com/${field_service_type_marker}
. I'm new to OpenLayers, so could easily have missed something (I'm surprised nobody else seems to be whining!).I've checked this both on the latest beta and latest from git.
TIA
Comment #9
zzolo CreditAttribution: zzolo commentedHi @AndyF, are you still having this issue. I am not really sure what the issue is, we are just passing that value to file_create_url()
Do note that the fix described above is only in the dev version (7.x-2.x).
Comment #10
AndyF CreditAttribution: AndyF commentedI needed to use strategy.cluster so I ended up using a bit of JS to pass a context function for the parametrised values, effectively overriding the OpenLayers style settings, so I'm not seeing it as an issue anymore. But apparently I did check against the latest (I can't actually remember specifically now!). IIRC
$style
as passed toopenlayers_render_style()
hasn't had the token substitutions done. So if you try the following as a drush script:It shows externalGraphic as
http://default/${field_service_type_marker}
(just tested with 2.0-beta1). The problem is that$field_service_type_marker}
is an absolute path itself, so that's where I think the double-up comes from. The way I got around it (before realising that clustering would screw everything up anyway!) was to use a computed field that returned the Drupal path (rather than absolute).Comment #11
zzolo CreditAttribution: zzolo commentedHey @AndyF. This should fix it: http://drupalcode.org/project/openlayers.git/commit/2fe8a72
Basically the issue was that if the value was just ${value} then the Drupal url function would assume it was a relative path and then just stick the base path on it. But, if it is solely that sort of value, then we should just pass it through to OpenLayers.
I also added some more tests for this.
Comment #12
AndyF CreditAttribution: AndyF commentedGreat stuff, thanks!
Comment #14
Mujtaba Ahmed CreditAttribution: Mujtaba Ahmed commentedin my view i have:
${count}
${name}
${field_location_rendered}
${field_location}
${title_rendered}
${title}
${#row_rendered}
${description}
I want to get value of ${count} and perform some calculations on it and again save ${count} in it. But cant sort out how it can b done. help needed.
Comment #15
Mujtaba Ahmed CreditAttribution: Mujtaba Ahmed commentedin my view i have:
${count}
${name}
${field_location_rendered}
${field_location}
${title_rendered}
${title}
${#row_rendered}
${description}
I want to get value of ${count} and perform some calculations on it and again save ${count} in it. But cant sort out how it can b done. help needed.
Comment #16
AndyF CreditAttribution: AndyF commented@Mujtaba Ahmed I think that should be a new support request.
Comment #17
stopshinal CreditAttribution: stopshinal commentedIn Views trying to change marker styles..
I have a field: ${field_allowed} which returns: "Y"
But I need it to return "Y.png" so externalGraphic will return website.com/Y.png as the marker style.
So I re-write the result.
Now ${field_allowed_rentered} returns: "Y.png" and ${field_allowed} returns "Y".
But externalGraphic still only returns "Y".
How can I set externalGraphic to return the field_allowed_rendered version? All the style setting allows me to select is field_allowed.
Comment #18
welly CreditAttribution: welly commentedI'm using the latest development version and I don't know if the bug has crept in again but I'm having the same problem.
In my custom marker style, I have set externalGraphic to this: sites/default/markers/${field_resource_type_rendered}.png
When I view the map, the marker image is broken and inspecting the element shows the following:
<image id="OpenLayers.Geometry.Point_78" cx="2871.4586186460515" cy="-1820.367046610685" r="1" x="2865" y="-1826" width="12" height="12" xlink:href="http://mapping.localhost/Marina" style="opacity: 0.4" fill="#ee9900" fill-opacity="0.4" stroke="#ee9900" stroke-opacity="1" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" stroke-dasharray="none" pointer-events="visiblePainted" cursor="inherit"></image>
In my View, the openlayers data is showing the following output:
For some reason the externalData value in the openlayers data appears to be the value used rather than the value set in the style.
Any ideas?
Thanks!