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 use the proximity search with views and it works fine.
showing the distance field and hiding it, if it is empty also works fine.
when i choose round and precission 2, then the "empty" fields with 0.00 will not be hidden.
does anyone has an idea how to fix this?
Comments
Comment #1
Golem07 CreditAttribution: Golem07 commentedI'd be very interested in a solution to this as well.
Comment #2
dmegatool CreditAttribution: dmegatool commentedYeah this is a bug. I'm not a coder so I don't have a fix or patch for it.
But here's how I managed to hide my field if it's empty.
<?php print round($row->field_geofield_distance, 1); ?>
Adjust the variable so it use your proximity field. The 1 is the precision so it will output ex: 3.1So that's about it, it should work. Note that this leaved me with an empty line caused by
<br></br>
in the DOM. I couldn't remove it so I hacked around with css like so :<div class="emptyDistance"></div>
.emptyDistance {display: block; margin-bottom: -1rem;}
in my css and it was all good. Of course adjust the margin to your liking if your doing this.
So all in all, we're just rounding using PHP instead of the default proximity field. It still should be fixed as this is a bug and users are expecting it to work.
Comment #3
dmegatool CreditAttribution: dmegatool commentedSeems like it's a Views issue ?
Discussed here. There's even a patch (I didn't test it).