Download & Extend

Location fields "Additional" not available to Views

Project:Location
Version:6.x-3.x-dev
Component:Location_views
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

G'Day:

Just checking to see if I've missed something in the way Location exposes its variables to Views...

Attempting to create a view, I go to add a field, choose the Location filter, and get all the Location fields avaialble through the CCK/Locative/Collection interface *except* the field "Additional"

I also see that in Views the group of Location variables includes something called "Address", which is presumably a "full address" version of the fields set up in the CCK stage.

However, I don't want a combined form of the address.

I just want to be able to pick out each of the fields and use them appropriately in my View. And at the moment, there is no access to "Additional"...

So imagine my surprise when I used the Views Bonus pack, CSV export, to create a data file... In this View (display type = Feed, format = CSV) I specifically chose only the fields:

Title
Street
City
Province

My exported data, however, also included the mysterious Additional...which was concatenated (post-pended) to the value for Street...thus making the data unusable!

Now:

1. Why isn't "Additional" shown in the Views/Location group?
2. Why does Additional get exported even when it is not specified?

Kind regards,

JB

Location 6.x-3.1-rc1
CCK 6.x-2.x-dev
Views 6.x-2.5

Comments

#1

I can confirm I can also not see the "additional" field option to display in Views. I also don't have the option for Telephone and Fax.

I'm using Location 6.x-3.1-rc1 and had Views 6.x-2.5, but have now upgraded to Views 6.x-2.6, which has made no difference.

#2

please try the dev version. Post back with your results. Thanks.

#3

Version:6.x-3.1-rc1» 6.x-3.x-dev

I can confirm that the additional field is still not exposed to views in 6.x-3.x-dev.

#4

Status:active» fixed

When adding a Location: Street field to a view you can choose a display style: Both street and additional, Street only or Additional only.

#5

Status:fixed» closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

#6

Status:closed (fixed)» active

Please provide a separate field. Sometimes a composite field is not desirable (eg: CSV output).

#7

Status:active» needs review

Here's a patch that provides this.

AttachmentSize
location-additional-field.patch 2.56 KB

#8

There is still no option to choose "Phone" or "Fax" for views fields. If I choose the full address, phone and fax numbers are not included in the output.

#9

note: the suggestion in #4 works in 3.1-rc1 (though it's very unintuitive)

#10

@lyricnz

A patch is not necessary, just add the field twice and choose a different option for each... I commend you on the effort though.

#11

@patcon
No, I tried this. It still doesn't print the Additional field, although it will print other Address block fields.
If I change it to a Node type View instead of a Location type View, it will provide CCK fields, though, and that will do what I need.

#12

I am trying to filter by the additional field, I have used it as a type field, will theis patch allow me to filter by the addtional field?

#13

No, it only provides a field for display.

#14

how would i make a filter to filter it by the additional field. Search on drupal sucks and i read all of the articles via google search and i cant figure out how to program a filter for this if it could save my life.

#15

I believe you need to use a _views_data function to define the filter handler
http://drupalcode.org/viewvc/drupal/contributions/modules/views/help/api...

You can likely use a filter handler, but if that doesn't work, you'll need to extend a basicr one:
http://drupalcode.org/viewvc/drupal/contributions/modules/views/help/api...

Can't see any reason why a basic text filter handler wouldn't work though, so you just need to tell views to use using the documentation in the first link.

#16

umm. hate to complain but is that major surgery? why cant it just show up in a drop down like a million other useless things do. this seems to be something none useless.

#17

I know I'll get heat over this, but I'm not on a system that I know how to roll a patch on -- haven't taken the time to learn yet. Someone just needs to do it once, then it'll be easy peasy for anyone else. Just hasn't been done yet.

#18

Hmmm... quick look in the most recent branch:
http://drupalcode.org/viewvc/drupal/contributions/modules/location/locat...

Search for $data['location']['street'] and you'll find this array:

  // @@@ 1.x Conversion -- 'additional' => 'street', style 'additional'
  $data['location']['street'] = array(
    'title' => t('Street'),
    'help' => t('The street address of the selected location.'),
    'field' => array(
      'handler' => 'location_handler_field_location_street',
      'click sortable' => TRUE,
    ),
    'filter' => array(
      'handler' => 'views_handler_filter_string',
    ),
    'sort' => array(
      'handler' => 'views_handler_sort',
    ),
  );

There already a filter handler defined, if I'm reading it right. Try a more recent version, or update this part manually in your own version? Good luck!

#19

nope you read it wrong.. i am looking for $data['location']['additional'] (if it existed, as it were)

#20

That doesn't exist (and won't ever). // @@@ 1.x Conversion -- 'additional' => 'street', style 'additional' is in reference to the fact that the additional field is just a "style" of the street field, i.e. you select "additional" from a dropdown in the street field settings :)

That function explains everything that has to do with the street field (display, sort, filter, etc), which INCLUDES the additional field (think of it as "street 2"). This function is where you'd need to replace the default filter handler views_handler_filter_string with some extension of the default handler like they've done with location_handler_field_location_street (an extension of views_handler_field).

See code for street field handler for evidence of this:
http://drupalcode.org/viewvc/drupal/contributions/modules/location/handl...

#21

@patcon, 'think of it as "street 2"' doesn't work at all when you can't filter by additional value (street filter selected) like any other field value. obviously it's a bug that needs to be fixed.

@tbillion: i managed to overcome this tricky thing by adding computed cck field which gets additional field value. later on you can sort by computed field easily. use rules module to update existing nodes (create simple view which shows all nodes and then create a rule 'update node when it is viewed'). it's kinda long way but works fine without extra coding.

#22

The handler needs to be written and committed. I've simply been trying to point out where it goes. I don't know what else to say.

Clever workaround in the interim though.

#23

Status:needs review» closed (works as designed)

For all those talking about filters this is not your issue.
This issue is for the "Additional" field only.
If you have issues with filters check for existing issues and open new issues if there aren't any that are relevant.

And as nickl mentioned in #4 this is already available.

The additional field is basically the street 2 field.
So in views you use the "Location: Street" field and for the "Display style" select "Additional only".
You can use the street field twice and in one instance use "Street only" and in the other use "Additional only".

#24

Status:closed (works as designed)» needs review

I needed a filter on the Additional field, it's very easy to add, patch attached.

AttachmentSize
location-additional-filter-dn481782.patch 571 bytes

#25

@nickl Thanks.. It took me a couple of hours to get me here and I couldn't have located 'Location Additional' field in the views without seeing this post. There was just no clue at all. I don't understand why they have hidden the 'Location Additional' field within streets. No clue at all.. But @nickl thanks for posting it here.. It works now..

#26

Status:needs review» closed (fixed)

The use case for filtering on the specific value of the "Additional" field narrow enough to not warrant supporting it. BTW, this thread is about adding the value of that field to the list of fields *displayed*, not filtered by.

If there still is a strong desire to be able to filter on the Additional field, my suggestion would be to discuss it further at #1380726: Location field "Additional" filter needed for Views in D7.

nobody click here