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.
The WKT field is not the nicest thing for end-users to see, so I'd like to propose a feature that allows the hiding (and showing) of it.
This post is a result of the issue discussed here: #881194: Configurable search address field position.
The attached patch uses jQuery to initially hide the field and creates a link that'll show it again (and vice-versa).
Comment | File | Size | Author |
---|---|---|---|
#2 | openlayers_cck-882190-2.patch | 2.14 KB | BWPanda |
openlayers_cck-toggle_wkt.patch | 1.07 KB | BWPanda | |
Comments
Comment #1
zzolo CreditAttribution: zzolo commentedHi @BWPanda. Many thanks for the patch. I am all about this, but there are a number of things not ideal with with your patch:
1) You are not using t() correctly
2) This should be in a separate JS file (unless there already is one for the CCK field)
3) You should utilize Drupal's JS settings to pass along the field name
Otherwise the idea is solid.
Comment #2
BWPanda CreditAttribution: BWPanda commentedThanks zzolo, glad you like the idea.
I've edited the patch to:
1) Use t() properly
2) Add jQuery code to existing .js file
3) Send field name and t() function output to JS settings
However, there's an issue when you have two maps on the same content type...
I have two OpenLayers maps on my Page content type ('field-location' and 'field-dummy') and the code doesn't work at all.
I ran an alert() in the .js file on 'wktField' and it outputs: 'field-location,field-dummy'. The PHP code is obviously adding the different fields to the same JS setting, but I couldn't work out how to fix it. If you can fix that for me, it should work fine.
Thanks!
Comment #3
zzolo CreditAttribution: zzolo commentedOk, committed. It is the way that PHP (drupal_add_js) does its array merges. It should be working fine:
http://drupal.org/cvs?commit=412908
Comment #5
Yanxi CreditAttribution: Yanxi commentedI am wondering if it's possible to completely hide the WKT field even without the link to show it? Or it would be even better to make it an option (display or not) in the administration interface.
Comment #6
tmcw CreditAttribution: tmcw commentedYanxi: no, that currently isn't an option, but it would be simple to use CSS to hide the link in your theme.
Comment #7
zzolo CreditAttribution: zzolo commentedHi @Yanxi. @tmcw makes a good suggestion. Though this would be a nice option to have for the CCK widget, so people don't need to have to edit a theme. You can create a new issue for the feature request if you want.