Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
If you have multiple addresses enabled for a content type, and create a view to display these addresses, it will only display the first address. I think it calls "location_views_field_handler_address", which only runs through the theme_location code.
Is there a way to display multiple addresses in a view if they exist?
Comments
Comment #1
catchStill valid in 3.x - using either an individual field or the 'address' field.
Comment #2
YesCT CreditAttribution: YesCT commentedNot ideal, but I wonder if you used contemplate, or a template file, if you used a for loop on the array, you could force all the addresses to print out?
There have been a lot of updates since July 2008, could someone, or the original poster try this again with the latest version please. I'll mark it as postponed, needs more info, for now.
Comment #3
YesCT CreditAttribution: YesCT commentedtagging
Comment #4
YesCT CreditAttribution: YesCT commentedNo reply, so marking closed. Please change status to active and add more info if this is still a problem for you.
Comment #5
Offlein CreditAttribution: Offlein commentedThis is still an issue. Views "Location: Address" outputs the first address, no others, no options.
Comment #6
Offlein CreditAttribution: Offlein commentedI forgot to reopen the issue..
Comment #7
YesCT CreditAttribution: YesCT commentedI know this has been draggin on a while, but there were a lot of changes in the new official release, Please check to see if this is still a problem in the new release. If it is, reply with a new summary and set the status back to active.
Comment #8
jason.lally@gmail.com CreditAttribution: jason.lally@gmail.com commentedThis is still a problem in the new release as well as the dev release. It will only display the first address entered in a list of multiple addresses. Any ideas on where to start looking? Is this a views problem or a location problem?
Comment #9
jason.lally@gmail.com CreditAttribution: jason.lally@gmail.com commentedWhen I run the views created query manually, I do get three locations back from the database. Where does views/location control the looping through these items? I'm just getting into views, what hook/handler controls the output of views?
Comment #10
jason.lally@gmail.com CreditAttribution: jason.lally@gmail.com commentedComment #11
jason.lally@gmail.com CreditAttribution: jason.lally@gmail.com commentedOkay,
Here's what I think I've found. I played with the output of the address handler (location/handlers/location_handler_field_location_address.inc). The render function looks like this:
When I played with outputting the content of $values->{$this->field_alias}, I get a single ID. That ID corresponds with the first lid returned by the query. I've been poking around at other analogous modules that output multiple values and can't quite figure out where the right place is to intercede. I thought views intelligently understood when multiple values were returned from a query and would render them "automatically."
Any ideas?
Comment #12
jason.lally@gmail.com CreditAttribution: jason.lally@gmail.com commentedAnother update: It seems that it will display multiple locations but it only allows you to break them out into separate rows and not group them into one row as multiple fields. This may not be a bug so much as a feature request.
If I have multiple values stored in a CCK text field, for instance, I have the option to group these. The same should probably exist for locations.
For example. I want a single block that can group multiple locations that would show up in an At A Glance type block on a page, taking the NID as an argument to display this information. There are ways around this, but they are all a bit hackish.
Comment #13
mr_scumbagYou say "Another update: It seems that it will display multiple locations but it only allows you to break them out into separate rows and not group them into one row as multiple fields"
How do you display the multiple locations ?
I cannot get it to output any location other than the first.
Separate rows would be fine for me, but only the first lid gets diplayed.
How did you get it to display multiple locations for a single node in views ? (Without views producing duplicate node entries with only the address different)
I'm using Location in CCK
Comment #14
rooby CreditAttribution: rooby commentedMarked #460674: Multiple location fields result in duplicate views results as a duplicate of this issue.
Comment #15
rooby CreditAttribution: rooby commentedA full description of the issue:
The "group multiple values" option that CCK provides for its multiple value fields is the kind of functionality we want.
If you use the "Content: Location" field in your view you can use the cck "group multiple values" setting and it will work. Note that this field didn't work properly until a patch was committed a couple of days ago so you will have to use the latest dev version.
However, if you use the views fields provided by the location module, such as those used for node locations, user locations and cck locations via a relationship to the location, it won't work. Because the location module doesn't support it yet.
That functionality will have to be added.
We need to keep the existing functionality as is (a separate row for each location entry) and add an option to "group multiple values" like CCK does. This was we don't break any existing sites.
If someone wants to make a patch you could use the cck code as a starting point.
The code is in the cck module in includes/views/handlers/content_handler_field_multiple.inc
Comment #16
rooby CreditAttribution: rooby commentedComment #17
ShaneOnABike CreditAttribution: ShaneOnABike commented+1 subscribe I'd definitely like this functionality
Comment #18
naught101 CreditAttribution: naught101 commentedExactly as #15 describes. This is going to hit me hard soon, so I'll try to have a look at it. No promises.
Comment #19
naught101 CreditAttribution: naught101 commentedHrm. As described in #15 ,
"Content: location" works, and that's good enough for my purposes, so I won't be working on this.Scratch that. I can use "Content: Location" for one field, but I need "Location: Province" for another, since the "Content: Location" field can't be split in to individual field value components, as far as I can tell..Clarification:
My set up: "Group" content type, with 3 different Location fields:
1) "Location" - physical home address of the group. Cardinality: 1
2) "Postal address" - as stated. Cardinality: 1
3) "Covered postcodes" - postcodes of all the areas in which the Groups work. Cardinality: unlimited.
What I want:
A table, with one row per group, listing:
- group name
- Province from "Location"
- all postcodes from "Covered Postcodes" united into one table cell.
I'm using "Content: Covered Postcodes" with a field re-write to combine multiple post codes successfully.
I have to use "Location: Province" because with "Content: Location" I can't get the province alone. It is THIS field that's causing the row duplication: the "Location: Province" appears to be trying to get the (empty) province sub-field from the "Covered Postcodes" and "Postal address" fields. I could get around this if I could use Distinct(nid), but #863478: Distinct is not supported by dbtng, so I think this has to be dealt with in location.
Comment #20
rooby CreditAttribution: rooby commentedRe #19:
Yeah, only the field provided by cck will do the multi value thing, but then you get the whole location, not just a part of it like the state.
So to group some and not others you would have to do some custom themeing for your view so that you get multiple post codes but not multiple provinces.
At least until this issue is resolved.
Comment #21
ShaneOnABike CreditAttribution: ShaneOnABike commentedping - any progress I don't really know how to set this up myself or I would attempt to write the code :/
Comment #22
ShaneOnABike CreditAttribution: ShaneOnABike commentedAlright well I have created the first patch to work with the Location: Country views handler, which was the problem that I was having for my site.
Note: I realize that this patch isn't applicable to *all* the different handlers but I wanted to start with one and the get the maintainers to check it out first before I go and deploy this on all the various handlers.
It took me a while to figure out all the handler code but after studying a few different ones I think I've got it. So basically it provides the option to output as a few different options (which can be overwritten theme wise I believe).
So feedback would be awesome and testing!!
Note: This only works (for now) with the Handler for the field not filters, argument, etc.
Comment #23
ShaneOnABike CreditAttribution: ShaneOnABike commentedOkay actually I changed this a bit more and added provinces to be output as well.
I had coded it to create an array with the results being in 'item' but I prefer to use the aliases already setup since I think that makes more sense. So here's the fix for country and province fields (this time using git properly)
Comment #24
ShaneOnABike CreditAttribution: ShaneOnABike commentedHere is the full complete integration I just need someone to test this out to make sure it works properly :)
Comment #25
ShaneOnABike CreditAttribution: ShaneOnABike commentedComment #26
gjmokcb CreditAttribution: gjmokcb commentedNot quite there. My view stores city, province, country. Hides the first two, then re-writes the third to include all three values. So the result of city: Kansas City, province: Missouri, country: United States is "Kansas City, Missouri, United States." With this patch installed and a second location added (Chicago), the result is:
Chicago,Kansas City, Illinois, United States; Chicago,Kansas City, Missouri, United States
Not separating the cities.
Comment #27
gjmokcb CreditAttribution: gjmokcb commentedOooog. And the view is displaying two identical instances. If I set "items to display" to 1, then it displays only one instance with only one city. So it's not grouping, and it's incorrectly displaying multiple cities.
Comment #28
gjmokcb CreditAttribution: gjmokcb commentedAnd I'm sorry to say that when you don't want to group values, just list (for example) people with their home town, line-by-line, the patch puts everyone's city on every line. So I've de-patched.
Comment #29
podarokbot?
Comment #30
podarokMultiple tabstops and trailing whitspaces errors should be fixed before RTBC
Also this needs manual testing and testing coverage
Comment #31
podarokAnd main trouble - this is feature request, not a bug, so before 6.x it shoud be filled and comited against latest 7.x-3.x-dev
Comment #32
podarok#24: location-views_handlers_complete-213792-24.patch queued for re-testing.
Comment #34
ShaneOnABike CreditAttribution: ShaneOnABike commentedHmm... not sure how to strip all those characters out. Seems when you tried to resubmit the patch doing so against 7.x is obviously going to fail.
Also for other folks testing this stuff I forgot that I also applied #752268: Print field-item wrappers for multi select lists even when only one item is selected. to make this work. I'm sorry for not mentioning that before. I think it makes a difference.
Comment #35
ShaneOnABike CreditAttribution: ShaneOnABike commented@gjmokcb: feel free to modify the code :) I set this up to work with just outputting singular items not the entire item (so if you just wanted cities not the entire location it should work from what I recall)
I'm not sure why this hunk would fail if there are spaces instead of tabs but I removed all that and resubmitting. Maybe the way this is being created isn't correct? With reference to modifying multiple files...
Comment #36
ShaneOnABike CreditAttribution: ShaneOnABike commentedComment #37
podarok#35: location-views_handlers_complete-213792-35.patch queued for re-testing.
Comment #39
skyredwangThe patch needs to go against 7.x-3.x-dev
Comment #40
skyredwang#35: location-views_handlers_complete-213792-35.patch queued for re-testing.
Comment #42
skyredwangI just made a smaller patch to test "group multiple values" for COUNTRY
Comment #43
skyredwangThe above patch only has ability to combine mulitple values but still cause the duplicates. It's not a real "group multiple values" option
Comment #44
Pepper CreditAttribution: Pepper commentedThe Views_distinct module takes care of getting rid of duplicates when I filter on node title.
However, this thread is 8 months old. I tried applying the patch to the current dev version but it failed, so I did it manually.
It seems to be working but I'm getting this error:
Strict warning: Declaration of location_handler_field_location_country::pre_render() should be compatible with that of views_handler_field::pre_render() in require_once() (line 9 of path\location\handlers\location_handler_field_location_country.inc).
Ideas on fix?
Comment #45
Pepper CreditAttribution: Pepper commentedAnother problem. This works, however, what if you want to list all the countries associated with a node, and link them _separately_ to something, oh, say a google map link.
Comment #46
Pepper CreditAttribution: Pepper commentedOkay, the patch has a small bug which is causing the error:
pre_render($values) should be pre_render(&$values).