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.
i couldn't get the variable styling replacement working in D7 following the guide at http://drupal.org/node/754480
it had already worked in D6. in D7 ${my_field} won't get replaced for the externalGraphic setting within my style.
also note that #1098760: Attributes and Styling variable list is empty might be related but didn't solve my problem either
Comment | File | Size | Author |
---|---|---|---|
#16 | openlayers_1127498_15.patch | 1.04 KB | bleedev |
Comments
Comment #1
dasjofrom http://drupal.org/node/1000012#comment-4053594 i learn that
for d6 this seems to apply and there is an example in openlayers_test. for d7 i couldn't find any info about Style Plugins so far
Comment #2
dasjoi'm currently investigating into using OpenLayer's internal styling feature
http://docs.openlayers.org/library/feature_styling.html
any help would be very much appreciated
Comment #3
dasjofinally came up with a workaround to dynamically styling openlayers in drupal 7 using openlayers rules:
add custom javascript for specific openlayers view
in yourmodule_openlayers_styling.js add the dynamics
i'm not a javascript expert, so there might be more elegant way to override Drupal.openlayers.getStyleMap
Comment #4
valderama CreditAttribution: valderama commentedsub
Comment #5
dgastudio CreditAttribution: dgastudio commentedsub
Comment #6
seanberto CreditAttribution: seanberto commented.
Comment #7
seanberto CreditAttribution: seanberto commentedI'm encountering this as well with the most recent dev release. I've got a view that provides a data layer. I'd like to use the content type's machine readable name as a variable in the externalGraphic file path. However, when the map renders, it looks like it's not picking up the variable correctly.
The following externalGraphic file path:
renders on the map as:
Comment #8
seanberto CreditAttribution: seanberto commentedFound the bug. Working on a patch.
@ line 108 im openlayers.render.inc we're turning relative URLs into absolute URLs for externalGraphics. This strips the ${} from variable names.
Comment #9
seanberto CreditAttribution: seanberto commentedFound the bug.
@ line 108 im openlayers.render.inc we're turning relative URLs into full path URLs for externalGraphics. This strips the ${} from variable names. Looks like this is b/c of the url() call. Not sure best fix.
Comment #10
zzolo CreditAttribution: zzolo commentedHi @seanberto. Good catch. So, it seems like this is just with the externalGraphic field.
I am not sure if there is an easy way to do this. The url() function doesn't have a way to turn off encoding. What can be done though, is, since we know what characters are being encoded, we can find-replace after the run through url(). A hack for sure.
Comment #11
dafederI would suggest just getting rid of the url function on that line. It's easy enough to manually set the path, but this makes it impossible to have variable marker images. We gain much more than we lose.
Comment #12
dafederWell, hadn't thought about the security implications. So a find-replace function would probably be the way to go. Will try to make a patch.
Comment #13
dafederThe logic here is confusing... URL won't make the changes you'd expect because it can't see what's in the variable. If I have a full path in ${variable}, it will get wrapped again in a drupal absolute path if I pass it through URL, even if it's de-encoded. Not sure how to proceed.
Comment #14
Jordanmt CreditAttribution: Jordanmt commentedI removed the piece of code that transforms relative paths thinking my variable would then go through -- but it returns "undefined" instead of the variable's value (which I can see in my views data layer).
E.g.:
...sites/all/icons/undefined.png
Is this a separate issue?
Comment #15
zzolo CreditAttribution: zzolo commentedThis should be addressed now. I did a simple replacement. It is by no means perfect, but should work.
http://drupal.org/commitlog/commit/4156/b48585aca7dda5c480832942551aa7b5...
Comment #16
bleedev CreditAttribution: bleedev commentedHi all, new engineer from ThinkShout submitting my first D.O. patch. I suggest the following patch to check if a variable is being passed from externalGraphic field.
Comment #17
seanberto CreditAttribution: seanberto commentedSeparate note - if this patch gets in, perhaps we should change the help text below the field to reference the fact that replacement patterns are accepted.
Comment #18
zzolo CreditAttribution: zzolo commentedHey @bleedev. Thanks for the patch. Maybe I am just missing something, but I am not sure I see the benefit of this extra check. Can you expand a bit?
Comment #19
bleedev CreditAttribution: bleedev commentedThe extra check is to allow the externalGraphic field to use ${attribute} syntax.
Comment #20
zzolo CreditAttribution: zzolo commented@bleedev . Maybe I am missing something but I think your logic is bad. You are creating a conditional that says:
If not absolute or full URL (ie Drupal path), AND has attribute replacement, then style the URL.
This is not good because we want to style the URL is it is a Drupal path, and then we add a little logic so that attribute replacements are not blown away.
This should be working fine now. Please re-open if I am missing something.