Currently running D7 & Location 7.x-3.x-dev.

Added a Location field to a content type, but it's content is not being saved. Entered data is not being displayed, nor shown when going back to the edit screen. Any idea what might be wrong?

CommentFileSizeAuthor
#308 location-n1064666-308.patch3.54 KBDamienMcKenna
#306 location-n1064666-306.patch3.6 KBDamienMcKenna
#269 location-supports-any-entity-type-1064666-269.patch3.09 KBgarphy
#268 loc_instance3.png8.29 KBfehin
#265 location-supports-any-entity-type-1064666-265.patch3 KBgarphy
#262 loc_instance2.png6.09 KBfehin
#261 loc_instance.png4.36 KBfehin
#238 1064666-supports-any-entity-type.patch2.92 KBgarphy
#229 1064666-supports-any-entity-type.patch2.33 KBgarphy
#202 location_cck-entities_support-1064666-202.patch4.49 KBlucascaro
#187 location_cck.zip4.62 KBruess
#181 entities_support-1064666-181.patch4.76 KBgrasmash
#176 entities_support-1064666-176.patch3.34 KBgrasmash
#169 location_field_collection-1064666-168.patch3.02 KBn3or
#167 working_port-1064666-150.patch1.02 KBmolnitza
#166 working_port-1064666-150.patch0 bytesmolnitza
#127 Screen shot 2011-06-11 at 11.57.57 AM.JPG43.27 KBbjlewis2
#127 Screen shot 2011-06-11 at 11.58.21 AM.JPG19.82 KBbjlewis2
#105 1064666-support-insert-and-update-user-or-profile2-location-info.patch1.02 KByaworsk
#104 1064666-location-profile2-update.patch631 bytesyaworsk
#86 1064666-full-node-and-user-test-clean.patch3.95 KBben kuper
#84 1064666-full-node-and-user-test.patch3.88 KBben kuper
#82 1064666-cck_node-empty-saving-fix.patch3.82 KBben kuper
#65 1064666 - location-user-field-update.patch776 bytesben kuper
#45 status-report-screen.png73.67 KBdrew29
#45 recent-log-messages.png81.03 KBdrew29
#24 location-undefined_index-1064666-24.patch1.46 KBrooby
#18 Bildschirmfoto.png33.59 KBdrew29
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tahiticlic’s picture

Same here...

Enabled modules are : GMap, GMap location, Location, Location CCK

tahiticlic’s picture

Priority: Normal » Critical
ben kuper’s picture

Title: Location CCK data not being saved » Location CCK & user location data not being saved

Same here, also with user location field...
I'm changing the title to not see this issue as a location_cck-specific behaviour.

ponderosa studios’s picture

I'm having the same problem. When I opened up my locations, all my location info is gone.
Sorry, I just realized I am working in 6. Maybe I am doing something wrong?

tahiticlic’s picture

That's the same in 6-x dev version as you can read here : http://drupal.org/node/906968#comment-4093032

bryancasler’s picture

I can confirm this problem in 7.x-3.x-dev

bryancasler’s picture

At one point I got this error, not sure if it is related

Notice: Undefined property: stdClass::$in_preview in location_cck_field_formatter_view() (line 302 of C:\xampp\htdocs\drupal7beta2\sites\all\modules\location\contrib\location_cck\location_cck.module).
rooby’s picture

@animelion:
I opened a new issue for that undefined property error as it is unrelated to this issue because it appeared a day after this issue started.
#1069150: Notice: Undefined property: stdClass::$in_preview in location_cck_field_formatter_view() (line 302 of location_cck.module)

Also, I notice your site is at C:\xampp\htdocs\drupal7beta2\
Are you still using drupal 7.0-beta2 or have you been updating as the new versions come out?

rooby’s picture

It is frustrating me that I can't fix this but I can't reproduce the problem.

Do you have any errors in the watchdog log (admin/reports/dblog) after saving?

@tahiticlic:
You mention an issue in #5, which is an issue about the fact you cannot use node locations on the same node type as cck locations (which is still the case and gives symptoms similar to what is described in this issue) but you say in #1 that you don't have the location_node module installed so that shouldn't be your issue.

johanbeckers’s picture

Same problem here with 7.x-3.x-dev (2011-Feb-19).
No locations are saved with Location CCK enabled.

The log shows me this:
Deleting unreferenced location with LID 3.

rooby’s picture

The error
"Deleting unreferenced location with LID 3."

is generally caused by having node locations enabled for the same content type that you are using cck locations on.

If you are only using cck locations disable the node locations module. Otherwise, for the content types that you are using cck locations on, set the max number of node lcoations to zero (on the node type edit page).

There are a few issues already regarding this and there is also a notice on the INSTALL.txt, on the project page and inthe location handbook on drupal.org - http://drupal.org/documentation/modules/location

Does anyone that is having this problem not have node locations and cck locations on the same node type?

ben kuper’s picture

No, In my i only have user location enabled and nothing else, and this isn't saving data too. This case could take away the possibility that this is coexisting modules problem.
Also, i tried with only location cck enabled and user location disabled, to be sure there is no crossing here.

Nikeev’s picture

Same problem with Location CCK. I tried to disable Node Location module, but data not saving too.

bryancasler’s picture

@rooby, I am on the D7.0 release, ignore the path name :) From the location module I only have "Location" and "Location CCK" enabled.

tahiticlic’s picture

@rooby, in #5 I give the cross post (comment #26 in fact) where lukebrooker says he has never activated the node location module but he has the problem.

That's my case : no node location, no user location, only CCK Location (it's useless to have both enabled I think) and no data saved. To precise, it's written here and there that CCK Location is the future of content location, so I've never activated Node Location or User Location.

Here is my config :

Address Field 7.x-1.x-dev
Administration Development tools 7.x-3.0-rc1
Administration menu 7.x-3.0-rc1
Administration menu Toolbar style 7.x-3.0-rc1
Block 7.0
Color 7.0
Colorbox 7.x-1.0-beta2
Config Exporter 7.x-1.0
Contact 7.0
Context 7.x-3.0-alpha3
Context layouts 7.x-3.0-alpha3
Context UI 7.x-3.0-alpha3
Contextual links 7.0
Chaos tools 7.x-1.x-dev
Dashboard 7.0
Database logging 7.0
Devel 7.x-1.0
Entity API 7.x-1.x-dev
Entity tokens 7.x-1.x-dev
Field 7.0
Fieldgroup 7.x-1.x-dev
Field SQL storage 7.0
Field UI 7.0
File 7.0
File Styles 7.x-2.0-alpha5
Filter 7.0
GMap 7.x-1.x-dev
GMap Location 7.x-1.x-dev
Help 7.0
Image 7.0
List 7.0
Locale 7.0
Location 7.x-3.x-dev
Location CCK 7.x-3.x-dev
Media 7.x-1.0-beta3
Menu 7.0
Node 7.0
Number 7.0
Options 7.0
Overlay 7.0
Path 7.0
Pathauto 7.x-1.0-beta1
RDF 7.0
Rules 7.x-2.x-dev
Rules UI 7.x-2.x-dev
Search 7.0
Shortcut 7.0
Standard 7.0
Styles 7.x-2.0-alpha5
System 7.0
Taxonomy 7.0
Text 7.0
Token 7.x-1.0-beta1
User 7.0
Views 7.x-3.x-dev
Views UI 7.x-3.x-dev
Wysiwyg 7.x-2.0

tahiticlic’s picture

Enabling MySQL log to see what happens, I think the problem occurs around line 893 of location.module (// Check anything that dropped a reference during this operation.). Here is the log, and as you will see, the location is inserted and then deleted, before the commit, that explains that the ID is not incrementing (self thought, I was wondering why) :

4652 Query DELETE FROM location_instance
WHERE (genid = 'cck:field_fiche_gmap:2') AND (vid = '2') AND (nid = '2')
4652 Query INSERT INTO location (name, street, additional, city, province, postal_code, country, latitude, longitude, source, is_primary) VALUES ('', '', '', '', '', '', 'fr', '40', '125', '1', '0')
4652 Query SELECT l.lid AS lid
FROM
location_instance l
WHERE (genid = 'cck:field_fiche_gmap:2') AND (vid = '2') AND (nid = '2')
4652 Query DELETE FROM location_instance
WHERE (genid = 'cck:field_fiche_gmap:2') AND (vid = '2') AND (nid = '2')
4652 Query INSERT INTO location_instance (nid, vid, uid, genid, lid) VALUES ('2', '2', '0', 'cck:field_fiche_gmap:2', '5')
4652 Query SELECT l.lid AS lid
FROM
location_instance l
WHERE (genid = 'cck:field_fiche_gmap:2') AND (vid = '2') AND (nid = '2')
4652 Query DELETE FROM location_instance
WHERE (genid = 'cck:field_fiche_gmap:2') AND (vid = '2') AND (nid = '2')
4652 Query SELECT COUNT(*) FROM location_instance WHERE lid = '5'
4652 Query INSERT INTO watchdog (uid, type, message, variables, severity, link, location, referer, hostname, timestamp) VALUES ('1', 'location', 'Deleting unreferenced location with LID %lid.', 'a:1:{s:4:\"%lid\";s:1:\"5\";}', '5', '', 'http://localhost/0268/node/2/edit?render=overlay&render=overlay', 'http://localhost/0268/node/2/edit?render=overlay', '::1', '1298404790')
4652 Query SELECT filename FROM registry WHERE name = 'FirePHP' AND type = 'class'
4652 Query SELECT filename FROM registry WHERE name = 'FirePHP' AND type = 'interface'
4652 Query DELETE FROM location WHERE (lid = '5')

Moreover, location_cck_field_update is called 3 times for an update, first and third times with items empty and second time only with correct items array. This leads to the deletion in location_save_locations function since the last time you have oldlids which contains an element whereas newlids is empty...

So, imho, the point is : why is location_cck_field_update called 3 times?

rooby’s picture

Thanks for the info, it should be helpful in determining the cause.

Will investigate further tonight.

drew29’s picture

FileSize
33.59 KB

Hej,

hope it helps, I have the same problem. Please look the screenshot. I have the position read marked. maybe that helps even to limit the error

kind regards
drew

wjaspers’s picture

I can confirm this problem as well.

Is there any reason to keep the User Locations or Node Locations modules in D7 anyway?
Since profile fields utilize CCK now, and Location CCK has the ability to become part of user registration ... why keep the "user locations" or "node locations" modules?

Can the Location module still recognize when a location already exists and re-use it? Will users be able to change it without impacting other content that uses the same location id?

johanbeckers’s picture

Regarding #10 and #11:
I did have node location enabled, but after some reading I disabled and uninstalled it.
Problem is still here.
I could give you admin access to Drupal and a DB user for phpmyadmin if this could help.
Just contact me.

patrickmj’s picture

Same issue, hoping this this Notice will help:
Notice: Undefined index: location_settings in location_cck_field_widget_form() (line 361 of modules/location/contrib/location_cck/location_cck.module

rooby’s picture

@drew29 re #18:
That "Array" problem is unrelated to this and the issue for it is at #1056148: 'Array' appears at the bottom of locations on node edit page

rooby’s picture

I'm having a look into it at the moment.

In the meantime, there has to be some reason why it works for me but not for you.
Maybe location is not playing nice with an additional module.

Can you try disabling contrib modules one by one and see if the problem goes away.
If you disable and not uninstall, all your data and settings will still be there when you re-enable.

rooby’s picture

@patrickmj re #21:
I would say that notice is not the cause of this but try this patch and see if it fixes the issue. It will at least fix the notice you are getting.

rooby’s picture

Also, there is apparently almost 300 people are using 7.x-3.x and there are only 10 of you in this issue so it must be something fairly specific to your setups.

rooby’s picture

@tahiticlic:

For me it never runs location_cck_field_update() when inserting and it only runs it once when updating.

Seeing as you are doing updates on node 2, have you also tried creating a new nodes and does it work then?

You could try debugging why it is called three times by enabling the devel module and adding the following code in the location_cck_field_update() function:

dd(debug_backtrace());

This will print a backtrace of function calls to a file called drupal_debug.txt wherever you have set your temporary files directory in your drupal site. This should defualt to /tmp, so in that case it will be at /tmp/drupal_debug.txt

If you post that file it will tell what is calling the function three times.

@johanbeckers:
SSH access or something similar, with write access to at least the location module directory would probably be the fastest way to debug the problem. But I won't be able to do anything for now as I'm going away for two weeks as of tomorrow (and it is nearly midnight here now).

rooby’s picture

As a start though, if anyone can try any of these it could help:
* disabling contrib modules until the problem (hopefully) goes away and reporting back which module was disabled when the problem fixed.
* try location with a fresh drupal install with no other modules and see if you still have the same problem.
* try the debug backtrace debugging mentioned in #26 and post the drupal_debug.txt back here (if you have previously been debugging with dd() please delete the drupal_debug.tzt file before you start so the file is fresh.

acarpio’s picture

Disabling Locale (in core) fix it for me.

drew29’s picture

thanks acarpio #28, fix it for me too, but now all my german translations and content are missing :-(

kind regards
drew

santhoshabraham’s picture

Same problem here. My locale module is not enabled. None of the Location field is saving.

tahiticlic’s picture

I confirm : without Locale, there's no problem anymore (I guess that the other users who had no problem were english speakers :-) ).

@rapadipayyan : check that both Node Location and User Location modules are disabled

bryancasler’s picture

I still can not get location data to save.

Current Setup:
Locale (Disabled)
Location (Enabled)
Location CCK (Enabled)

bryancasler’s picture

Per #26's request. I hope this can help resolve this issue.

2.35mb -> http://k.min.us/ilPgEI.txt

Screenshot of profile fields

http://awesomescreenshot.com/0ab865g30

The following is the only info I added to this profile.

Username: John Doe
Email: johndoe@johndoe.com
Location: 1600 Amphitheatre Parkway, Mountain View, CA 94043, United States

bryancasler’s picture

I just created a fresh minimal install of D7.0. I've only enabled what is necessary to perform the backtrack per #26's request. In the end I was still not able to save location data.

Core Modules Enabled
Block
Database logging
Field
Field SQL storage
Field UI
Filter
Menu
Node
Overlay
System
Text
Toolbar
Update manager
User

Optional Modules Enabled
Location CCK
Devel
Location

I did this for comparison to my previous post which was not a fresh install.
2.17mb -> http://k.min.us/ijzKKK.txt

The following is the only info I added to this profile.

Username: John Doe
Email: johndoe@johndoe.com
Location: 1600 Amphitheatre Parkway, Mountain View, CA 94043, United States

Can someone who has had success with getting locations to save, can you post what core modules you have enabled. It should also be noted that I am developing locally, not sure if this could be influencing the outcome. I'll conduct further test and report back.

bryancasler’s picture

Just tried the current D7.x-dev with the current Location 7.x-3.x-dev, still a no go on getting location data to save.

acarpio’s picture

@animelion: In core I have it just as it comes when you install drupal. Previously, Locale was the only one I enabled by myself and I found made Location CCK not to save.

With that setup (core as it comes) plus Location and Location CCK, Location CCK is saving for me. I'm developing locally also.

When you say "The following is the only info I added to this profile.", what that means? was that information saved and displayed? What fields it is coming from?

I'm not expert but I'm trying to figure out why it is saving for me and not for you.

bryancasler’s picture

What I mean by "The following is the only info I added to this profile." is that for the user account I created, the only information I added to it was "Username, Email and Location". Username and email are required to create a user account. After creating the account I then tried to save a location for that user.

bryancasler’s picture

Just tried the same setup I had on #35 on a live server (Rackspace Cloud Sites). I still had no success in getting node locations to save.

Anonymous’s picture

Having same problem. Have retried from backup without GMAP but still same problem.
Unable to store any of the location data in a NEW content. On the contrary location data entered in the content type definition is saved.

Anonymous’s picture

I started disabling all modules systematicly. When having only a few core modules and Location CCK and Location enabled the problem still existed untill I also disabled Locale in core.
Languages used are English and Dutch.
So disabling Locale made it work.
Hope this helps the clever people to pin point the cause.

Anonymous’s picture

I played around enabling and disabling and it surely is caused by Locale from the core modules. If I delete any other language and so only keep English as only language with Locale enabled then the CCK data is saved.
Any workaround available for this? Because I need the Dutch interface.

bryancasler’s picture

sbruynin, I've never enabled the locale module and I'm having this problem. So I do no think that's the source of this issue.

WilliamV’s picture

subscribe

bryancasler’s picture

Can someone who has locations saving please post as much details about your setup as possible. What version of D7 your using, what modules you have enabled and versions, every .htaccess and setting.php tweak, etc...

I've done everything I possibly can to help move this forward, I'm not really sure what more I can do.

drew29’s picture

Hej,

I test it on XAMPP for Linux version 1.7.4 ! and I use drupal 7.0 from drupal.org

only these core modules I have enabled:

locale
user
Text
System
Node
Menu
Filter
Field SQL Storage
Field
block
update manager
database logging

contributed modules i have enabled

Location CCK 7.x-3.x-dev
Location 7.x-3.x-dev
Gmap 7.x-1.x-dev
Gmap Location 7.x-1.x-dev

I have test it with clean and without clean url's I don't have a htaccess for the local installation.

hope it helps, when you need more Information please contact me :-)

kind regards
drew

bryancasler’s picture

Thanks drew29, I'll mirror this setup as best I can in the morning.

bryancasler’s picture

drew29, I still had no luck. Have you made any changes to your location or gmap default settings?

"admin/config/content/location"
and
"admin/config/services/gmap"

Also, what are your settings for the location field?

acarpio’s picture

Well, so far we have identified (comments #28, #29, #31 and #40) that Location CCK is not saving when Locale is enable, I’m opening a new issue with that, to clarify and asking to be addressed since we international people depend on that. I hope I’m doing the right thing opening a new issue.

@animelion:
I’m developing in a mac with apache and php 5.3 that comes with MacOs 10.6, MySqul and PhpMyAdmin 3.3.8, location CCK is saving. And, as I explained in #36 , drupal core modules as they come as installed and Location + Location CCK enable: Location CCK is saving. It just stop saving when I enable Locale.

For sakes of testing, I just installed a fresh Drupal in MAMP, I installed and enabled only Location and Location CCK, I did not make any change on Location configuration, I did not change settings for Location CCK… It is saving.

Could be a problem with your installation?

bryancasler’s picture

Hurrray! 50% Success!

I've been testing adding a location field to a user "admin/config/people/accounts/fields" and this is what continues to fail. I just tried saving location data to a node and I had success! So this solves 50% of the problem. So my new question is, can anyone get a user location field to save?

As for user location I've tested setups locally on xampp with PHP 5.3.5 and mysql 5.0.77 and on live site (Rackspace Cloud Sites) with PHP 5.2.13 and mysql 5.0.77. Both local and live I've tested D7.0 and D7-dev. I'm using the latest copies of Location and Gmap and I haven't made any changes to .htaccess or settings.php. I've tried saving a user locations field as both user 1 and another authenticated user with the proper permissions set, but I've had no success.

acarpio’s picture

@animelion
Ok, I get it now... I was always talking about location CCK in nodes, which is saving except if I enable Locale.

You are right, when adding a Location CCK to "admin/config/people/accounts/fields", it is not saving.

Anonymous’s picture

I have no problem saving user location (with and without Locale enabled). The only problem I encounter when saving the user form is that the system doesn't return to the correct page but nevertheless the data was correctly saved. In my case only CCK locations causes saving problems. I tested this on a new LAMP server and on a new Drupal7 install (without local languages installed).

bryancasler’s picture

@sbruynin, I'm using cck locations for my user profile fields. I am not using the profile module, but instead D7's built in fields support.

Agence Web CoherActio’s picture

subscribing

Anonymous’s picture

I noticed that the CCK were deleted during the content/save process and a message was generated in the log:
"Deleted unreferenced location with LID ##"
I touch to have spent to much time already on this problem and temporarly modified location.module to avoid deletion of these unreferenced LID's. I commented out part of the location_save_locations function (the last if-statement) and now the CCKs do not disappear anymore.
I do not know what other consequences this can have but for now I'm happy to continue working on the rest of the site until a solid permanent solution is found.
Probably not a nice solution but for me a workaround for the time being.
Use this "workaround" with care as I said I do not know the consequences of this modification.

bryancasler’s picture

sbruynin, thanks for the suggest I just commented out the following (the last if statement in the location_save_locations function) from location.module

      if ($count !== FALSE && $count == 0) {
        watchdog('location', 'Deleting unreferenced location with LID %lid.', array('%lid' => $check));
        $location = array('lid' => $check);
        location_invoke_locationapi($location, 'delete');
        db_delete('location')
          ->condition('lid', $location['lid'])
          ->execute();
      }

Nothing seems to have changed, I still can not save user cck location fields. On a side note I never saw "Deleted unreferenced location with LID ##" in my log messages.

Anonymous’s picture

@animelion,
It looks as there are various causes for the problem. I understood that your problem is not influenced by the enabling of the Locale-module as is on my installations. Have you tried on a test-site to chmod the whole site to 777 to check for permission settings errors?

Reen’s picture

I can also confirm this problem. I tried disabling the local.module which resulted in bug #1056030: Notice: Undefined variable: dash_index in location_get_postalcode_data_de() in supported/location.de.inc, which was easy to fix. Without locale.module I can save location data without problem. Contact me if you need access.

macman91’s picture

subscribing

drew29’s picture

Hej,

@sbruynin thanks a lot it works for me too :-)

@animelion please try to comment out these lines :-)

    /* if ($location['lid'] !== FALSE) {
        $newlids[] = $location['lid'];
        $instance = array(
          'nid' => 0,
          'vid' => 0,
          'uid' => 0,
          'genid' => '',
          'lid' => $location['lid'],
        );
        foreach ($criteria as $key => $value) {
          $instance[$key] = $value;
        }
        db_insert('location_instance')
          ->fields($instance)
          ->execute();
      }*/

hope it helps

greetings
drew

wjaspers’s picture

Based on my understanding of the Location module's inner workings:

Preventing location from using the instances table may be dangerous. The reason it was implemented is to reduce duplicate locations in the database.

Take, for instance, a Location CCK field named "Territory" applied to a "Company" content-type. For our purposes, we'll say the "Territory" consists of a state and country. Each Company we add to the database may cover the same states ... eg. Company A's territory is "Nebraska","Iowa","Missouri"; Company B's territory is "Nebraska","Kansas","Utah"; and Company C's territory is "North Dakota","South Dakota", and "Nebraska". Instead of the database having three instances of "Nebraska", it only needs one.

This has a three-fold advantage: we can reduce the number of geocoding requests to our favorite maps providers (Google, Yahoo, Bing, etc...), we can identify locations that are related to more than one piece of content, and we prevent our database from rapidly filling with duplicate records.

If some content needs to change its location data, the module first checks to see if any other content points to it. If there is other content related to it, a new instance is to be created. If the new data already exists in another location record, the database simply changes what it points to.

Based on comments #55 and #59, it looks as if the code as mentioned in #59 is supposed to pre-populate an instance based on "$criteria". How this is established, I am not sure. If the code in #55 is being called, then my best assumption is an empty instance is being created, and then removed. By disabling the code in #59, my assumption is that a location is created without checking for an instance. This will allow the module to work, but not identify duplicate locations.

bryancasler’s picture

What a PITA

elgandoz’s picture

Hi Guys! I had the same issue, no saving Location CCK in nodes. My current site is in Italian (default), English, French, so i have to keep Locale enabled (for client UI).
After trying some times with Node Location (it's my first time in D7 with Location), even if working as desired I choose to move on Location CCK for better handling/styling. So I encountered this issue.
After reading this issue queue, I simply tried to:

  • Disable and uninstall* all unecessary GMap/Location modules (only
  • Set "Multilanguage support" enabled in the content type main options (before was disabled)
  • Save my node with "Independent from the language" option

That's it, so I had Location working. Still have no geocoding working for Italy, even if I am sure it was in D6.
Please try and report (perhaps I was simply lucky!!)

I'm using 7.x-3.x-dev version of this module, with all module up-to-date and no customization on IIS 7.

* I was unable to unistall GMap Location it gives me a white screen with Fatal error: Call to undefined function db_fetch_object() in /web/htdocs/www.swisscontrolsystem.com/home/sites/all/modules/gmap/gmap_location.ins... on line 28

smilterman’s picture

Having the same problem.
Disabled everything I could.
User location just will not save.

Any help at all would be much appreciated.

Grtz

wjaspers’s picture

Category: support » bug

Maybe we'll get a better response if this is classified more accurately as a bug report.

ben kuper’s picture

I finally had some time to do a quick search about location cck as a user field not saving.

The location_cck_field_update & location_cck_field_insert trigger the location_save_locations() only when the form_id is "node", so when updating a user location cck field, nothing happened.
I tried invoking the location_save_locations with passing the uid in the param object. It seems to work for me !

For the record, i have locale enabled and french as default language.

wjaspers’s picture

Status: Active » Needs review
bryancasler’s picture

Works for me!

Here is a patched location_cck.module for everyone else who is stuck on windows.
http://pastebin.com/shKT4JKV

smilterman’s picture

Title: Location CCK & user location data not being saved » Location CCK patch worked but now isn't displayed in user info

Well what do you know.
Applied the patch and fields are being saved now.

Thanx a lot proffy for this patch.

Next problem for me now though is that the information isn't being displayed on the user info page.
I get location: and then no info at all. In the account settings it is properly configured to display.
Any thoughts on this?

Thnx again for the patch.

bryancasler’s picture

Ohh snap, same problem with it not displaying.

jamesbenison’s picture

This module was ported from D6 where fields were only added to nodes. And it appears that parts or it are still written to work only with that entity type. Users don't have a vid. Parts of the module need rework to get it to work with any entity.

If I get time I'll try to help with a solution. Proffy's patch looks to be a start.

smilterman’s picture

ok, thnx for all the hard work you guys.

I f u understood how this all works, I would gladely help to make it work.
Sadly enough, I am just a user who appreciates the good work :)

ben kuper’s picture

Title: Location CCK patch worked but now isn't displayed in user info » Location CCK not saving : patch worked but now isn't displayed in user info

I know this will be an annoying answer, but after a bunch of fail attempts to understand why the field wasn't rendered, i got it working and didn't know why either.... I finally decided to revert to the original file with only the previous patch applied and it was still working...
My opinion is that the viewing process seems to work, maybe it's a caching problem or something like that.
Try to clear the cache, and maybe after applying the patch, try to save the location again, maybe change some values in it and then try to view it.
Unfortunately, i'm not able to get back to a non-working scheme so i hope this will work for you.

Thanks for the motivating comments and leave feedbacks about what's happening with your setups.

Time to sleep.

Ben

smilterman’s picture

Just to keep you updated...

Tried reinstalling the module, cleared cache before and after, applied the patch, cleared cache. re-saved the info, changed the info...
But halas, same result, info saves but doesn't display.
I'll keep on trying different methods, hoping I will find one that works.

smilterman’s picture

Hi again,

I got the location display working by fiddeling around with the user account settings. At the bottom of that page is also a part that handles the location. I changed the minimum location number and Location form weight. That did the trick for me. Now I can't seem to get it not working again :)

Other problem that I'm facing now is that the location field in my view isn't showing the info.

2 problems solved, one to go :)

Chirio

ben kuper’s picture

Hi, good to hear that, and also frustating because there's still an issue which seems to be really random & arbitrary....
I didn't test the view integration yet but i had a quick look at the view function, which also seem to not integrate the user-related field possibility.
When i'll be on the view integration job (really soon i hope), i'll keep you posted on my searches.

Cheers,

Ben

jamesbenison’s picture

@smilterman

The situation you are describing to me seems like it involves the user locations module rather than the location cck module. Please correct me if I am wrong.

@proffy

It makes sense that the location cck widget won't work with views when attached to a user. As I mentioned in the post above, CCK was written only to handle nodes since that was the only thing it could get attached to in D6. It needs to be converted to the entity concept. The user locations module does work with views. I have tested it.

ben kuper’s picture

Really soon was actually now.
Sad news (for you), i'm able to see the location fields values in both user view and a location view...

This post is actually originally about location cck not saving values, and i guess all the problematic scenarios aren't resolved yet (especially for node location cck).

I suggest you to start a new issue for the views integration problems, this will make this thread more relevant for the data saving problem, and not mixed up with other problems.

ben kuper’s picture

Sorry james, there was a cross post.
I understand you, and i'm actually surprised that it seems to be working well with just tiny bit of additionnal code.

I'm in a hurry for the website i'm building and even if i agree with you on the entity api conversion, it is a huge modification and i can't wait for this to be done... But i will follow the progression with a lot of interest !

WilliamV’s picture

Location data is still not saving, but after the last workaround by rooby, location cck in preview-node-screen is showing.
Above solutions are not reliable.
Is dev-team programming on resolving this issue, if so, what is their deadline?
We have a project based on cck location.
Thx & Grtz.

smilterman’s picture

wow, WilliamV, u sure have a strange way for asking for a solution nicely. Being that drupal and all of it's modules are completely and totally free...
I'm sure these guys are doing there utter best in finding a solution!

Anyhoozle: I did mix up the cck location and user location a bit. I'm not a pro at all, so I have a little bit off learning to do I guess.

As I said earlier, location is showing up in user profile now and I created a user view that also shows the location correctly.
But now, I changed the module from user location to node location and now that one isn't saving the information...
What I wanted to do in the first place is create a node view where the location shows up, but it doesn't.
I guess this is related to the node location not saving the info now.

thnx again for the great work guys.
Looking forward to the finished module for drupal 7, which by the way is awesome :)

WilliamV’s picture

@ Smilterman - I can't see what was wrong with my question? Just made a resume of all submitted information and asked a concrete question. No harm meant at all. Dev-team knows that (most of) the drupalers over here respect and appreciate their work.

Grtz.

ben kuper’s picture

thanks smiltermann for explaining the spirit of the drupal community.

@WilliamV
I'm also in a project that needs to move faster, but i chose D7 because i knew i could help the module's issue fixing and digg into code.
If you're really in a hurry and can't dev for these issues, i strongly recommend you to base your project on a D6 core, that will be more stable and you won't have to wait for all the modules that are being ported to D7 to be fully functionnal.

As jamesbenison said, the solutions & patches we may post in this issue are only workaround, until the full data workflow is converted to the new entity api.

Ok, now the good news :) --> It's only concerning node saving, but as smiltermann's problem is also about location cck node, the view problem might be solved with that too.

I may have found a tiny solution based on #16 experience. I did find also a 3 times call to the location_cck_update function. I don't know why and honestly don't want to digg further in this direction since it would be looking into the whole field hook system and why it's reacting strangely...

What i've found is :
- the 1st call is empty, maybe to initialize the db record. (?)
- the 2nd call is the actual data saving, and this works great until -> the 3rd call which is also an empty call BUT saved over the 2nd (real) call.

So i just did a quick verification on the location data array to verify if it's empty or not. (in the location.module, location_save_locations function).
I also added at the end of this function a //drupal_set_message() to test when saving if the function is done or not.

For those who know better the code than me, i would understand that saving empty values could be necessary for the actual module's workflow.

I tested this workaround and it seems to work.

Anyway, test the patch and leave feedback as usual !

Even if you're only using the location cck as user fields, download this patch because i fixed something to handle better location field deletion

smilterman’s picture

@WilliamV

William, if no harm was intended, then no harm is done :)

@proffy

I tested the last patch and it seems to be working fine for the cck_location. I turned off the user location and node location to be sure off what I was working in. I see the difference now :)

With the patch from #82 for cck_location: fields are saved in nodes and users. Field are displayed in nodes, users and views.

Only litle hickup for me now is that, when I save the information in a user cck_location, I get the following message:

"Notice: Undefined property: stdClass::$vid in location_cck_field_update() (line 197 of C:\xampp\htdocs\gamesruilen\sites\all\modules\location\contrib\location_cck\location_cck.module)."

Doesn't seem to interfere with the saving or displaying of the info though.

ben kuper’s picture

Glad to hear that :)
Yeah i just copied a line and forgot about changing vid to uid...

This patch should solve that.

EDIT : I looked up a bit more in others function, like delete and found a lot of problems coming... For example, i don't think locations will be properly deleted if a user is deleted or even if a location field inside a user is deleted.
So for really simple usage, this patches will do the trick but continuing to add those workarounds are just more and more work that could be spent on an actual entity api conversion...

WilliamV’s picture

@Proffy : great patch!

•location_cck_field_update, node
•location_cck_field_update, node
•location_cck_field_update, node
•location_cck_field_update, node
•location_cck_field_update, node
•Event xyz has been updated.

Thank you kindly!

ben kuper’s picture

Status: Needs review » Patch (to be ported)
FileSize
3.95 KB

Oh shoot, still forgot one debug message...
Clean patch, here it is

Thanks for feedback William !

For the full Field / Entity API Conversion, let's go there : #1061266: Merge node/user/taxonomy/cck locations to use fields API for everything

bryancasler’s picture

Status: Patch (to be ported) » Reviewed & tested by the community
ben kuper’s picture

Title: Location CCK not saving : patch worked but now isn't displayed in user info » Location CCK not saving
Shadlington’s picture

Subbing

JVA-1’s picture

If this is final, when will it roll in the dev tarball?

ben kuper’s picture

i think rooby's in charge of this issue, but he's on vacation for few more days.
You can contact other maintainers to ask them if they can commit it.

rooby’s picture

Title: Location CCK not saving » Location CCK not saving for entities other than nodes

- Changing the title to be more specific.
For people who are having the locale module related problems see #1075210: Location CCK not saving when Locale is enabled.

I have only just got back and quickly skimmed over this issue so this is just a quick comment, I have not yet read through all the posts in here since I left.

The location 7.x-3.x branch is supposed to be a direct port of the 6.x-3.x branch and location 7.x-4.x will be a rewrite to better utilise the new features of drupal 7, like fields.
This means that the location cck module has been ported to provide the functionality of location cck in drupal 6, that is, adding location fields to nodes. That is why location cck fields only work for nodes, not users, taxonomy and whatever else. I was pretty sure I documented this somewhere but I may not have or it may not be in an easy to find place, I'll have to dig it up.

So with the current version you can use:
* user locations, provided by the user locations module
* node location, provided by the node locations module
* location fields on nodes, provided by the location cck module
* taxonomy location, provided by the taxonomy location module

You can also use location cck fields on users indirectly by using the Profile 2 module.

This is just like in the drupal 6 version.

Now support for fields on other entity types can be implemented, like the patch does, but then we would have to go further and provide support for other entities, turning this into a location_field module instead of a port of the location_cck module. The idea of this was dismissed in #692938: Drupal 7 port for location module, where it was preferred to keep location_cck as is for 7.x-3.x and fully support the field API in 7.x-4.x, which will do away with the sub-modules for node locations, user location, taxonomy locations, cck locations and just use fields for everything in the main module.
(I haven't played with 7.x-4.x-dev much yet so I don't know how much of this is already working.)

This might be frustrating for people but the reason for this was that we get 7.x-3.x working as fast as possible so that it has all the functionality of 6.x-3.x, as a direct port, without worrying about any major changes to how anything works.
Then when 7.x-4.x is complete, which will take longer, there will be an upgrade path from 7.x-3.x.

So technically this is a feature request, which would put it against 7.x-4.x as that is where new features go, and I don't think this should be committed to the 7.x-3.x branch due to it being a direct port/no new features version.

But you should be able to use location cck for users with the profile 2 module, just like in drupal 6 with the content profile module.

tahiticlic’s picture

@rooby : for Locale, is there a solution? Cause even with nodes, location_cck won't work if Locale is enabled, and the post you refer links to this one...

rooby’s picture

The other issue is still for the locale problem (which is separate to this one).

The references to this issue in that one are for clarification on the splitting of that issue out from this one.

jamesbenison’s picture

@rooby

Thank you for the update. I'm glad to hear about the plans to include an upgrade path. It sounds like you have everything well covered. Makes total sense to me.

bryancasler’s picture

If I use Ben Kuper's patch in #86, will this prevent me from upgrading smoothly in the future from 3.x to 4.x?

ben kuper’s picture

@animelion :
As rooby said, the 3.x branch is a straight port from the 6.x version, and no features like user's location cck field support will be added to it.
My patch allow this version to add the user's case support in the location saving process by adding the uid in the entity saved in the location_save_locations function. I basically made this patch to be rapidly able to save user's location with the location cck module and i don't realy know how it could interfere with the upgrade.
I don't know much about the upgrade path that will be done from 3.x to the 4.x version but i don't think this will be a big problem.
Maybe rooby will have a different point of view...

Shadlington’s picture

RE #96: I imagine if rooby implements user support in a different way you would have data loss on your users, as I doubt an upgrade path would accommodate this patch.

rooby’s picture

There was previously a note on the project page regarding this but I made it a bit more clear.
If you think it needs anything else let me know.

Re an upgrade path from the patch in this issue:
The upgrade path will be from the standard 7.x-3.x to 7.x-4.x (or from 6.x-3.x if coming straight from there) and won't cover any uncommitted patches.
However the patch doesn't deviate far from how the normal location cck data is stored so I don't don't imagine it would be at all hard to write something to get your data from this patch to the 7.x-4.x version.

bryancasler’s picture

I would much appreciate that if it wouldn't be too much of a hassle to include.

rooby’s picture

zabelc’s picture

Hate to say it but, I believe that the patch in #86 needs to be adjusted for the current dev structure. I just attempted to apply it and got the following results:

patching file location.module
Hunk #1 succeeded at 842 (offset -1 lines).
Hunk #2 succeeded at 901 (offset -1 lines).
Hunk #3 succeeded at 1362 (offset -1 lines).
Hunk #4 succeeded at 1591 (offset -1 lines).
patching file contrib/location_cck/location_cck.module
Hunk #2 FAILED at 165.
Hunk #5 FAILED at 190.
Hunk #7 succeeded at 205 (offset 4 lines).
Hunk #8 succeeded at 223 (offset 4 lines).
Hunk #9 succeeded at 248 (offset 4 lines).
Hunk #10 succeeded at 250 (offset 4 lines).
2 out of 10 hunks FAILED -- saving rejects to file contrib/location_cck/location_cck.module.rej

The result of this failure is that I receive the following WSOD:

PHP Parse error:  syntax error, unexpected T_ELSE, expecting ')' in /home/patcms/public_html/sites/all/modules/location/contrib/location_cck/location_cck.module on line 192

PS apologies for entering the duplicate issue...I keep associating CCK with D6 and just skipping anything with that name...

yaworsk’s picture

Hi all,
I still can't seem to get location data entered into profile fields to save to the database.

I have Location 7.x-3.x-dev from March 28 installed and the following modules enabled:
- location
- location cck
- location phone
- location search
- profile 2
- profile pages
- and some other contrib.

I tried applying #86 and #65 patches but both times I got a no changes message. I'm gonna keep looking into it but wanted to throw my hat in the ring in case anyone else is still having trouble.
Pete

yaworsk’s picture

I found a solution in the location_cck module file. For those having an issue with Profile2, the attached patch should help, it accounts for different entity_types beyond nodes.

I know this version should work with profile2 but it wasn't for me and in the event it isn't for others, I hope this helps.
Pete

yaworsk’s picture

Scratch the previous patch - forgot to update the insert function so the first time you saved location data for a profile, nothing would save. The update function worked though...

revised patch attached.
pete

tonycpsu’s picture

Subscribe

rooby’s picture

Status: Reviewed & tested by the community » Needs work

I think that leaving this unresolved is going to cause too much annoyance in the issue queues as it is pretty confusing and restricting.

And seeing as though there doesn't seem to be a way to restrict fields to particular entity types I think this will have to go in.

The way everything works in the background will be redone in 7.x-4.x but I will still make 7.x-3.x location_cck field work for all types of entity and just use the existing location_instance setup as drupal 6 (like the existing patches in here do).

Marking as needs work as it needs to be a more generic solution that works for all types of entity.
I'll have some time to do this on the weekend.

bryancasler’s picture

Thanks Rooby, rabble rabble!

Jerome F’s picture

Patch in #105 helped to save the informations in the location form. But nothing is displayed under the location label on the profile view page: users/foo - so the data is saved and not displayed.

There are two options at this point I understand, either going on patching 7.3.x to make things work temporarily or making things integrate smoother in Drupal 7 entities in: http://drupal.org/node/1061266 Joachim, Profile2's maintainer explained briefly why that kind of issue would happen in Profile2 here: http://drupal.org/node/1040038#comment-4348828

andrebonfanti’s picture

subscribe

shadcn’s picture

Patch in #105 works for me. Thanks yaworsk

Location CCK 7.x-3.x-dev and Profile2 7.x-1.0-beta2

bryancasler’s picture

I just spent the last couple hours trying to get the patch from #86 to apply. Could someone throw me a lifeline and see if they can get it to apply cleanly? I've tried both the dev and stable release, but both have been a no go. I tried both automatic and manual application of the patch. I'm hoping someone else with a little more know how could help out.

paulgemini’s picture

subscribe

jeffschuler’s picture

subscribing.
Thanks, rooby, for your explanation in #92 that Location CCK 7.x-3.x is currently only intended for use with Content Types.

mkaiser-1’s picture

We're on 6.2 and I had the same issue with Location CCK not saving. I disabled the module Location Add Another and saved. Then disabled Node Locations and saved. I was finally able to save the fields to my content type, but my GMap wasn't working. When I enabled those same modules again, my fields saved and my map worked. Hope this helps someone.

I spoke too soon. I'm able to get the fields to save, but my map still isn't working.

Glottus’s picture

subscribing

Anonymous’s picture

I'm using drupal 7 and i used the patch to make use of this module and now it will save BUT won't appear.

Field label is "Location" and it's the only thing that's showing up.

Anyone got a clue?

wjaspers’s picture

Probably needs the Render API to help out.
whatever field template is present, should look similar to this. print render($variables['location']);
Otherwise check your display formatters for the location field to make sure they're not set to 'hidden'.

Anonymous’s picture

Is it possible that it is not showing up because i'm using the CCK fields on users profiles?

cjamesrun’s picture

subscribing for 6.x. Tried 115. When I re-enable, and go to edit it wipes all of the info out of the CCK fields for secondary (mailing) location.

gooney0’s picture

Subscribing

Halarikeyur’s picture

Issue tags: +location user

I did a fresh Drupal install with only core module along with location but still can't save user location information.
PLEASE HELP.........

Halarikeyur’s picture

I did a fresh Drupal install with only core module along with location but still can't save user location information.
PLEASE HELP.........

Jerome F’s picture

@Halarikeyur : don't use the location field use the node location instead for the moment. the location field is not ready imo. In the locative information tab set Minimum number of locations to 1 in /admin/structure/types/manage/your_content_type and configure it. configure everything in /admin/config/content/location

Halarikeyur’s picture

@Jarome F: Thanks a lot for your suggestion. This should get me going...:)

ann_meredith’s picture

subscribe

bjlewis2’s picture

FileSize
19.82 KB
43.27 KB

I'm allowing users to enter their contact info into a Profile2 field.

Modules Enabled:

  • Location CCK
  • Location
  • Location Fax
  • Location Phone

Previously I was unable to even get the info to save. I was able to apply the patch from #105 successfully, and it does indeed make it so that the location info is saved. Now I'm having the same problem as #109, where it is saved, but not displayed. I've attached a couple of screenshots to show the edit screen and the display screen.

Is there an approximate eta for the 7.x-4.x module? If it is anytime soon, I might just wait for that to be ready and do it the proper "Drupal 7 way". Otherwise, I'll need to find a way to make the 7.x-3.x module work for now.

Thanks so much for all of the hard work being done on this module!

bjlewis2’s picture

Sorry... Double posted

spessex’s picture

Issue tags: +profile2

Same problem. Used the patch in 105 which at least retains the information in the 'Edit' user information (which it didn't before) but like 109 it can still not be viewed in 'My Account' view or 'My Main Profile' view.

I really need this to work.

Does anyone know of another way to add location to 'Create New Accounts' signups? Specifically UK locations that provide drop-down lists of towns etc i.e. pre-populated data fields? I'm still new to this so although Profile2 (which is what I'm having problems with in terms of saving location) does appear to be the right solution (if locations worked) perhaps there another way of doing this which I have overlooked?

Thank you

Stephen

Summit’s picture

SUbscribing, greetings, Martijn

Anonymous’s picture

I tried the "hack" from #105, but with multiple location fields on one page, the locations deleted each other. You have to add in a unique 'genid' to make it work. Below is my adaptation, which works for my profile2 fields.

In location_cck.module, change the following functions to look like: (based on patch from #105)

/**
 * Implement hook_field_insert().
 */
function location_cck_field_insert($entity_type, $entity, $field, $instance, $langcode, &$items) {
  if ($entity_type == 'node') {
    if (!empty($items)) {
      // Store instances of locations by field name and vid.
      $criteria = array(
        'genid' => 'cck:' . $field['field_name'] . ':' . $entity->vid,
        'vid' => $entity->vid,
        'nid' => $entity->nid,
      );
     }
  } 
  elseif ($entity_type == 'user' || $entity_type == 'profile2') {
    $criteria = array(
      'genid' => 'cck:' . $field['field_name'] . ':' . $entity->uid,
      'uid' => $entity->uid,
    );
  }
  location_save_locations($items, $criteria);
}

/**
 * Implement hook_field_update().
 */
function location_cck_field_update($entity_type, $entity, $field, $instance, $langcode, &$items) {
  if ($entity_type == 'node') {
    if (!empty($items)) {
      // Store instances of locations by field name and vid.
      $criteria = array(
        'genid' => 'cck:' . $field['field_name'] . ':' . $entity->vid,
        'vid' => $entity->vid,
        'nid' => $entity->nid,
      );
     }
  } 
  elseif ($entity_type == 'user' || $entity_type == 'profile2') {
    $criteria = array(
      'genid' => 'cck:' . $field['field_name'] . ':' . $entity->uid,
      'uid' => $entity->uid,
    );
  }
  location_save_locations($items, $criteria);
}

As you can see, I added the 'genid' => 'cck:' . $field['field_name'] . ':' . $entity->uid, part to the patch from #105

lynnjdsmith’s picture

I got this error when I had 'Node Locations' turned on. Turned it off, problem fixed for me. Seems strange, but I'm having no problem associating locations with nodes, with that turned off. I have a cck field on a content type.

Olivier Boulanger’s picture

Subscribe

kunago’s picture

Without this being functional the module is not yet to be used even in testing because there is not much to test. I found a notice above the function "location_cck_field_formatter_view" which says "@Todo: This".

Looking at the code in the function it is obvious that it cannot display anything in the user profile. The variable "element" should be carrying all the information to be displayed but the only place it is set is at the beginning and it's value is an empty array.

Modifying the code to make it work is feasible but I am not sure whether useful because once developers of this module decide to implement a way to save and update the location cck on non-node entities and the approach is different to what was said already, manual patching might become very useless.

Could developers please make the module save and update information for non-node entities for the start? I would be more than willing (and I bet I am not the only one) to provide formatter patch but it needs to be consistent with the database and the developers goals.

designguru’s picture

Category: bug » support
Status: Needs work » Fixed

Just in case any one else stumbles upon this thread after pulling their hair out wondering why their CCK Location field isn't working in Drupal 7; make sure that Locations are disabled for that content type by going to Structure>Content Types>Blog (or whatever type you're using) and then setting the # of locations to Zero (0); that will make sure that there aren't attempts to save duplication location IDs per node!

Keep up the good work everyone,

Qasim./

Anonymous’s picture

Category: support » bug
Priority: Critical » Normal
Status: Fixed » Active

Hi,

how is the original issue fixed?
"Location CCK not saving for entities other than nodes"

I still can't use location for profile2 profiles or user account. See my hack attempt at #131 to make it at least work with profile2.

I suggest to keep this open until we have a solution. Kindly let me know if I've misunderstood something.

rooby’s picture

Status: Active » Needs work

Back to needs work as there is a patch there that needs a bit extra.

I will have some time to work on this very soon so we can make a 7 beta release.

Arnion’s picture

Subscribe

Summit’s picture

I think it would be great to have this on 7.4!
I am investigating Drupal 7 more now, and see the benefits of fields working and node/term references instead of the "old" drupal 6 way. It would be great to have location follow this path of fields instead of the D6 way.

Right now the D7.3 Location gives for instance every location field attached to a vocabulary or node, but with D7.4 I think it should be fields-like so you can choose on content type or taxonomy or whatever content to add location fields seperately, right?

Thanks a lot in advance for considering this.
greetings,
Martijn

boonep’s picture

subscribing

fubhy’s picture

#139 - Yes... Field definitely have to overrule directly node/entity attached locations at some point.

Summit’s picture

@fubhy, hopefully that some point is more sooner than later...
greetings, Martijn

Shaunikm’s picture

After update on 7.x-3.x-dev July 16, Location again stopped saving, did patch #105, now save but not show in location view. So update still haven't solved the issue?

Jarode’s picture

The same issue, again and again... It's been for more than 5-6 month I need a fix to begin a subproject. :-(

Hydra’s picture

subscribung

Lerain’s picture

#134 designguru

You sir, made my day. Thanks a bunch! :)

Barry1337’s picture

I cannot display the location of a user when using the profile2 module. Is there any solution yet?

daemonsy’s picture

Subscribing - I've been refreshing location mod for Drupal everyday, waiting for location 7.x-4.x... =(
If only my programming is a little better, maybe can still help.

lamefork’s picture

Subscribing. Hoping to utilize this with Profile2 as a basis for user indexing.

seddonym’s picture

Subscribing too. I have a client with a relatively urgent need for this, and a budget. If one of the module maintainers has any thoughts/direction on the underlying issues surrounding this I could probably do the leg work, as I'm a relatively experienced Drupal developer. I just don't know the Location module very well.

rjbrown99’s picture

Similar experience to #134, using location 7.x-3-x-dev july 16, creating a location field for a (core) user profile. Field is visible in the user profile, ajax-iness works to load values such as states, but saving does not work. The changes are lost upon save.

clubfootnz’s picture

Subscribing. Similar Xp to #134 and #151.

deanflory’s picture

Version: 7.x-3.x-dev » 6.x-3.x-dev
Priority: Normal » Critical

Just ran into this after deciding to switch from node location to CCK location and for D6 it's not saving, nor displaying a map. It IS however saving the phone field and is displaying the phone field (fax not tested).

Could it somehow be tied into the node location not allowing the Country field to be turned off like the others (plus setting to 0)? I'm a newbie but just stating some things I've noticed in case it helps.

Not having this work is well, making the module rather useless to me and/or requiring me to do double work+. Any idea on when this might happen as it's been half a year since the original issue submission? Thanks for all your hard work!

bjlewis2’s picture

Version: 6.x-3.x-dev » 7.x-3.x-dev

Woah! Don't go changing the version on us.

This issue is for the 7.x version, if you are having a problem with the 6.x version search the 6.x issue queue and if you can't find anything open a new issue under 6.x.

deanflory’s picture

Sorry, thought I changed it back before sending. My bust.

blainelang’s picture

Test case that may shed some more light into this issue: Using the location field on a content_type and it's been working fine until .. we added a new content_type that also used the location field and can not save any of the location field data for this new content type. Still can save the original content type nodes.

I first looked to see if there were any known limitations to using the location field on more then one content type and having not seen any reports, realize my issue may be the same as this issue even though it had been working fine for us.

At this point, we are very nervous the first content_type may start having issues saving the location data so we are going to have to remove it from use on this project. This issue is a critical and should be fixed asap.

blainelang’s picture

When I read comment #135, about the workaround to solve the save issue, I was not able to find the setting or set it the way it was explained. I was looking in the wrong area -- I was setting the number of locations in the settings for the field I had added to the content type. There is no 0 option, it's 1, some number or unlimited.

If you look at the vertical tab options when editing the content type, where the 'publish options are set' there is a 'Locative information' tab -- select that tab.

This makes no sense but if you set the 'Maximum number of locations' to 0 (as in don't show any), it will still show the location field and it SAVES the data. Set this to 1 (default) and NO SAVE. I've tried this now adding the location field to two content types and both now save.

Maybe someone else can verify this works for them (until this issue is fixed and then we have to remember to change it most likely).

ktleow’s picture

Subscribe
Am having the exact same prob, no Locale installed.

However, on a fresh clean installation, it works! Strangely.

MrRoxy’s picture

Subscribe
Same problem if I create a location field on a taxonomy.

Ingmar’s picture

sub

ChrizUK’s picture

@morningtime This added code to patch #105 allowed the location data to be saved to a user profile type (profile2).

Still can't get it to show up though, it displays the Location: Label but no information.

Profile2 7.x-1.0 with location & location cck 7.x-3.x-dev

elBradford’s picture

Subscribed. Crazy it's been an issue this long. I wish I had the time to contribute, eagerly anticipating a fix.

paulgemini’s picture

Here's my question -

The work being done here by the community is great, helpful, and hugely appreciated. But I wonder if this energy might not be better spent on finishing 4.x using the Field API (instead of creating a patchwork fix to the old approach).

Again - don't want to step on any toes here, and perhaps the folks who are working on this are also working on 4.x. Or perhaps no one's working on this. I have no idea. Just throwing that out there. As a relative novice who can test patches and create small patches, I know I'm not in any position to dictate work flow with any credibility. And maybe I'm completely misunderstanding this.

Anyway, just my two cents, submitted in the most humble and appreciative way I know how:)

daemonsy’s picture

I agree with Paul. I've been one of those novice programmers visiting once every 2-3 days to look for location 7.x-4.x. After a while, I gave up and tried using 3.x to realize it's pretty choppy unless you just want to save node locations. I can only wish as I'm not good enough to contribute to the code and neither can I pay for someone to write something with functionalities of location.

Will it be better if we can have an estimate of roughly when 4.x will be out? I for one, rather have a timeline to work with rather than trying to male 3.x work then after that 4.x is out.

kpojeta’s picture

patch in #105 worked for me using devs of Profile2 and Location CCK - but as others have said, the actual display of the content isn't working - label shows up, just not the content. it doesn't show up on the node page or a views rendering either

molnitza’s picture

Should work with the current dev release. It is a port of th patch from comment #105.

molnitza’s picture

Upps... here is the right patch.

n3or’s picture

Same problem here, but in relation to field collection items. I try to develop and release a patch next time, to offer the possibility to use location with field collection items.

n3or’s picture

Here the patch for #168. Please review this patch.

There is no warranty! Use for productive sites at your own risk!

dgastudio’s picture

after apply the patch from #167 everything seems working right but:

Notice: Undefined property: stdClass::$partial_match in google_geocode_location() (line 133 of /home/u4586/domains/**/sites/all/modules/location/geocoding/google.inc).

is this related?

semanthis’s picture

#169 solved the Problem for field collection items. Thank You

craigmc’s picture

Subscribe

bjlewis2’s picture

@craigmc please don't post "subscribe" to issues any longer. Use the new "Follow" button at the top right of every issue queue. It helps keep posts on topic, and removes all the fluff. :)

Ingmar’s picture

I'm still experiencing the same problem for profile2. The location is saved, but is not displayed.

Aldus’s picture

I'm also experiencing the problem. Trying to add a location cck to an user (profile2).. after saving I have:

    Notice: Undefined index: location_settings in location_cck_field_widget_form() (linea 364 di /var/www/confestetica/confestetica/docroot/sites/all/modules/location/contrib/location_cck/location_cck.module).
    Notice: Undefined index: location_settings in location_cck_field_widget_form() (linea 364 di /var/www/confestetica/confestetica/docroot/sites/all/modules/location/contrib/location_cck/location_cck.module).
grasmash’s picture

Status: Needs work » Needs review
FileSize
3.34 KB

combined patches from molnitza and n3or.

Added my own modification to address issue mentioned in comment #174

grasmash’s picture

Status: Needs review » Needs work

patch generates error when locations are deleted. will look into.

Ingmar’s picture

Good to see work is being done. Gonna test this as soon as possible!

RaulMuroc’s picture

Status: Needs work » Active

I'm not sure if the following trouble is because of the patch or because of Location search sub-module itself.

Anyway. I used the last patch, it let me to introduce Locations CCK in profile entities :-) nice. I have Location search activated. And thne in Search settings I put 'Active search module: Location search and use it as default. It is detected 4 items left to index but when running cron it doesn't index at all. If i try with anoder 'Active search module: nodes' then yes, it detects another items and indexes them perfectly.

I guess it is something related to: The patch + Location CCK + any antity not expected before the patch.

Anonymous’s picture

Latest dev-x does not even save data for nodes! I added a Location CCK field to a node, entered address & saved. Then re-edited the node: EMPTY fields for the data I just entered.

grasmash’s picture

Status: Active » Needs review
FileSize
4.76 KB

Updated patch. This now support deleting locations via location_cck. Seems to work for me, but I'm not 100% sure that I did it correctly, so a few reviews would be helpful!

magicmarkker’s picture

Subscribing, I applied the last patch and I still can't get Locations to save on taxonomy terms.

grasmash’s picture

ah, taxonomy terms. I don't think anything has been added for that. Right now, the patch handles Profile2 profiles, nodes, user fields, and field collections. A bit of extra code to handle taxonomy terms will have to be added.

rooby’s picture

I apologise for not having the time for this that I said I'd have (I do feel bad about not being able to get back to it).

As has been mentioned previously in this issue it is somewhat wasted effort to continue to put time into 7.x-3.x when it will be replaced very soon by something else, which is why I will probably not spend any more time on it.

There is however a new plan for a successor which is just about to get underway.

As of about 2 weeks time, I will be able to invest the time required to get that done and as a rough estimate I figure we should have something usable early next year (by which I mean mid January).

For more details see: #1346746: Roadmap for next gen location (7.x-5.x)

In the meantime you are more than welcome to continue to work on this if you need it now, however there will most likely not be an upgrade path from this patched set-up (unless you also write that :)).

damonatodd’s picture

Category: bug » support
Status: Needs review » Active

Can someone please upload a zip version of the fully patched module as I've been trying to figure out how to patch the file correctly for the past 3 days.

Thanks in advance,
Damon

bjlewis2’s picture

Category: support » bug
Status: Active » Needs review

Damon,
By changing the status from needs review to active, you would prevent the maintainer and other bug fixers from knowing that there is a patch here waiting for review. And, while I realize that you are requesting support, the purpose of this thread is to report the bug of not saving locations.

When you change those settings, it changes the entire thread, including the original post from February.

Feel free to ask for fully patched modules, but please don't change the issue its self.

ruess’s picture

FileSize
4.62 KB

Hey damonatodd,

Attaching the specific file that the patch fixes. Simply rename the old version of this file to "location_cck.module-old" and paste this one in the same folder. The folder is: \modules\location\contrib\location_cck

This did it for me I'm happy to say -thanks to those who submitted the patches and looking forward to a brand new 7.x-5.x!

damonatodd’s picture

Thanks for the heads up bjlewis2 I'll remember that next time. Also, thanks for a quick response ruess as I hope this works...

Unfortunately this didn't work for me The address still doesn't appear :(

Damon

grasmash’s picture

Found one error in this patch: if you leave the location_cck field blank, it tries to add an empty location without field criteria. Simple solution. Change line 184 to:

  if (isset($criteria)){
    location_save_locations($items, $criteria);
  }

Other than that, I'm using this in production without issue.

ankur’s picture

Version: 7.x-3.x-dev » 7.x-5.x-dev

Maybe it was clarified somewhere in the previous 189 comments, but this isn't going into 7.x-3.x, but can be considered for 7.x-5.x.

rooby’s picture

Yeah, 7.x-3.x is pretty much DOA, 7.x-5.x will support other entities from the get go.

mr.h’s picture

I confirm in D7.10, Location 7.x-5.x-dev, no patch above works on clean install. I read all thread and the outcome is: some patches will save cck field but not render formatter. Locale has nothing to do with this bug. also, Profile2 has nothing to do with this bug. please only test on clean install. I continue to test myself. sorry for my English.

planctus’s picture

Could someone who followed this issue briefly update everyone about its state?
I've tried patching the 7.x.3 as per #184 but it didnt' fix the problem, now i'm reading about the 7.x-5 and nothing seems to work here too...
So am i right while saying that, as of now, there's not a working release of the cck_location module for D7?
Thanks,
Da.

rooby’s picture

@planctus:
cck_location in drupal 7 (7.x-3.x-dev) is at a similar level as is drupal 6 was, which means it works for nodes but not all the other new drupal 7 entities.

Also see comment #184

I don't know the status of these patches themselves but from the last comment above yours it would appear they currently don't apply to the latest version.

planctus’s picture

Well, not in my case...
I'm using 7.x-3.x-dev and it is not working for me with nodes.
I have the form elements in the node form but nothing get saved.
It happens with the "standard" module as well as with the version in comment #184.
I'll keep trying but i don't know exactly what else i could try...
Thanks,
Da.

rooby’s picture

Only thing off the top of my head is if you use node locations and cck locations on the same node type it doesn't work.
See #906968: CCK Location Fields do not save when Node Locations are enabled. and the known issues section of the project page and README.txt for information.

If it isn't that something unusual must be happening.

planctus’s picture

That was the reason...i had to disable node locations ;)
I know it is off topic here, but is the authomatic coordinates retrieval supposed to work with location_cck?
cause it seems it's not... :(
Thanks,
Da.

rooby’s picture

Yes, geocoding should work. Try searching the issues by version 7.x-3.x-dev and search for geocoding and see if there are any issues that match your problem. Otherwise just create a new issue with a description of the issue.

kevinquillen’s picture

Which one of these patches do I need so my custom entity works?

RumpledElf’s picture

Just hit this one myself - trying to use CCK location on a user.

The user location module works fine but it is a bit of a shock to the system finding out that the field you put on a bunch of content types and users has been silently failing all this time because location CCK doesn't work. There's no indication at all that you can't use location CCK on users until it is too late.

kevinquillen’s picture

Yeah. I really cannot find a way to get this to work, I at least need to work with the data in Views.

lucascaro’s picture

Love It!
I've just applied the patch from #181 and it's working for profile2. Awesome!

I couldn't apply the patch using git apply, though, so I had to use patch -p1.
I've attached a patch that is the same as #181 but made with git so it can be applied using git apply.

Cheers!

Edit: just to clarify, this is for 7.x-3.x-dev

kevinquillen’s picture

This still does not really solve the problem of being able to use this with custom entities and now I see the 4.x branch that people said to use a few weeks ago is now abandoned. I applied the patch and mimiced the changes to support my own entities but still does not work, the only thing I can save is a location record, no instance is generated.

How far along is 5.x? Can it be used to simply collect a location and display a map with Gmap?

Edit:

I re-patched the module for my own needs and it seems like a good solution would be to have a final else case that does:

- Set $criteria to $entity_id and genid to the entity type

This worked for my custom entity without explicitly hard coding it. The location address then appeared on my entity view render, and the map did as well. THe only part I am stuck on now is getting the map coordinate picker to appear on entity add/edit forms.

kevinquillen’s picture

After looking further, the above is not a good solution because it fails on insert and you don't want to track lid (its tracked on the Field anyway).

It seems that location_instance table should be made to hold entity_id and entity_type, possibly another field to hold serialized data (revision id, additional data), then the functions that lookup location data would need to be rewritten... maybe I should look at the 5.x branch to see whats transpired, but it doesn't seem like it would take much to get this going. That to me seems like a better approach, and that it would usually always work, unless I am missing something?

blackandcode’s picture

The previous patch works but doesn't work for taxonomies. Can anyone do the patch that works for taxonomies? I see that the problem is in the functions location_cck_field_insert and location_cck_field_update these functions don't have elseif statment in case of taxonomy. For example:

elseif ($entity_type == 'taxonomy_term') {
// some crietria i don't know what criteria to put
}

Can anyone do the rest of code?

kevinquillen’s picture

I just found that I had to manually add a field for my entity id (in this case, listing_id) and set that as the criteria ($entity->listing_id, $items[0]['lid'], 'listing') so that the record saved in the correct place. That should create a record for the id, the lid it points to, and the entity saved under. Thats where I entered the line of thought that location_instance needs to have its schema changed to store entity_id, entity_type, and possibly a data table of serialized data (vid, any other information).

Heres what you can do to get it running:

- Add 'tid' integer field to location_instance.
- Adjust the criteria in the CRUD functions for taxonomy_term to be $criteria = array($entity->tid, $items[0]['lid'], 'taxonomy')

Double check and see that $entity->tid is correct by dumping out $entity. It might be taxonomy_tid or something like that.

Again, in my case adding the entity specific field was the shortest path to getting Location 7.x-3.x working with the patch a few posts above with custom entities. YMMV.

Alan D.’s picture

As per the tag, an quick update in the Issue summary would save many users grief.

Currently, I read this as:

=============================================================

Issue status

3.x: Location CCK only works on nodes and not other entities. Patches #xx and #xz have had reportedly good outcomes.
5.x: The renamed Location Field (hint hint - cck is dead) is planned to be supported on all entity types but it is still in development and shouldn't be used on a production site yet.

The teams current focus is in getting the 5.x branch ready for a semi-stable release. We are not planning to support non-node entities in 3.x.
=============================================================

I hope the core dev's still have high spirits, this is such a big task on an established module. I still prefer this module to AF :)

kevinquillen’s picture

Is there a timeline or timeframe on it? With things like Entity Construction Kit and other Entity minded modules coming along, Location support is integral- well for me at least.

wiherek’s picture

Version: 7.x-5.x-dev » 7.x-3.x-dev

Confirming: patch from #181 works with Location 7.x-3.x-dev version. I am using GMAP and it successfully assigned the location on the map based on the address I provided.

kevinquillen’s picture

But does it work for Taxonomy terms and other custom entities? To me it looks like it only adds support for field collection items, user, and profile2. It did not work for me out of the box, I had to add my own lines in for my entities as well as two fields into location_instance table to store them correctly.

bkat’s picture

I hacked location_cck to work with profile2 entities at http://drupal.org/node/1445782

jschoder’s picture

Subscribe. I have the exact same problem with Location in users and in Profile2-entities.

Looking forward to a release containing the fix.

Fixdit’s picture

Subscribe.

locavore’s picture

In the user Profile I have added the Location field, and of course it does not save the data. BUT if I save it in the user Account area it saves fine. Of course I do not want it in the Account area, I want it to show in the Profile.

Does that provide any clues?

bjlewis2’s picture

@Fixdit Stop subscribing, and start following as per http://drupal.org/node/1306444

kevinquillen’s picture

Pardon me if I am wrong- but won't there be a problem assigning entity id's into the nid field since entity id's can overlap with node id's? You can have a node id 1 and profile2 id 1- will that cause problems in other areas of Location? This is why I just added my own field into the table and patched in support.

jlongbottom’s picture

I am having the exact same issue.

nd987’s picture

Surprised this is still an issue over a year later.

rooby’s picture

Your welcome to do a rewrite of location for drupal 7 entities/fields and post the patch if you like and I'd happily make some time to review it.

kevinquillen’s picture

For anyone needing a solution now, AddressField + GeoField + Geocoder + Openlayers works. I know its more than Location + Gmap, but it will get you there.

rooby’s picture

Re #220:
I can confirm that too.
+ field_collection & text fields if you want additional things like phone & fax.

It isn't a complete feature match between that and drupal 6 location but it covers a lot of use cases.

ivanilic’s picture

Assigned: Unassigned » ivanilic
Priority: Critical » Major

My solution works only with enabled node location.
I added new map contenty type and location field .
In every other content type where I want to show the map - just did two things:
1. Add existing field location field.
2. Hide all date concerning node location and put all numbers to zero.

garphy’s picture

Hi Folks,

I've been working (really really quickly) on a wrapper module around location_cck. It promotes a new field type (location_field) and need location_cck to be enabled. It also need the entity contrib.

It tries to reuse all it can from the location_cck module. There is no care of handling properly any kind of content revision aspect. No fuss on formatters either, it only reuse the default one.

If I can grab somebody's interest in testing that piece of code, at least it performs well there in saving location associated to nodes (really?!) and profile2 without any patching.

The key point is the format of the genid : "field:field_name:entity_type:entity_id".

This is mainly a PoC but I think it could be the best approach to extend location_cck in 3.x branch.

5.x need to take a radically different approach by getting rid of any nid, vid, uid, whatsoever in the location_instance table and provide decoupled integration mechanism with 'things' it's being referenced by. Or better : being an entity and leverage entityreference.

Code is there : http://drupal.org/sandbox/garphy/1493472

Cheers !

rooby’s picture

You seem to have removed the HEAD branch of your sandbox and are using a 7.x-3.x branch, which means the clone command given on your sandbox page doesn't work.

To clone it you have to use

git clone --branch 7.x-3.x http://git.drupal.org/sandbox/garphy/1493472.git location_field
rooby’s picture

I haven't got time to properly review this or test it on a site right now but from a quick glance at the code the concept seems good.

And because it doesn't do anything crazy with the location_instance it should be easy to make an upgrade path when the new 7.x-5.x branch finally gets done.

fehin’s picture

I am thinking of using the address field module but would be possible to upgrade to loaction 7.x-5x once it's ready?

Nchase’s picture

the location_field sandbox module is working fine for me... what about integrating it into location cck instead of having an own project?

fehin’s picture

@Nchase, how did you download it? The link didn't work for me.

garphy’s picture

I haven't got time to properly review this or test it on a site right now but from a quick glance at the code the concept seems good.

I refactored the concept as patch for location_cck.
It doesn't alter the original behaviour when entities are nodes and apply the logic on all other entities (implementation of the "else").

As the first proposal, it doesn't probably handle properly the "entity revisioning" concerns.

The patch doesn't alter the .info but it should be noted that a dependency to 'entity' is added.

rooby’s picture

@fehin:
If you mean will there be an upgrade path from addressfield to location then no. Not in this module anyway.
It would be possible for you to write your own code or database queries to do so though.

Or else you or someone else could probably write a module that migrates from one to the other and post it to drupal.org so other can also use it (if it is generic enough for other to use.

You might also be able to use something like node export to export nodes to csv, then you could do any data manipulation required to go from one to the other and then import it back again putting the location data into a different field.

rooby’s picture

@fehin:
See #224 for instructions on how to get the sandbox project.

fehin’s picture

I'm sorry for being a slow poke but how do I download the files from sandbox/git?

Update: Figured it out using the instruction here http://kylecordes.com/2008/git-windows-go. (Without the creating an account with git part.)

garphy’s picture

Don't hesitate to give a spin to the patch too. In the end it works the same without having to enable two modules...

rooby’s picture

If the patch is the same as the sandbox it's probably better to review the patch anyway as that is what could potentially be committed to location 7.x-3.x.

pinkonomy’s picture

I used the patch from #229 ,but no luck.The locations is being saved and you can see it when Editing the user profile,but when I am saving the user profile the map is missing. :(

pinkonomy’s picture

I mean when adding the location field to panels the map doesn't appear.Insted of the map appear these information:United States
39° 5' 45.4668" N, 22° 19' 27.1884" E
See map: Google Maps
How can I make the map to appear instead of the above information?
I also take this message on the panels region:
It seems to me that the 'Map' formatter doesn't appear on the panel to select from.Any thoughts?
Thanks

Jing He’s picture

I applied the patch #229 in my environment. Now insert and delete location field data for entity type 'user' works fine. But it seems that the hook location_cck_field_load is not implemented yet. Please have a check of it.

garphy’s picture

Yes you're absolutely right about it.

I somehow missed that when re-rolling my proposal as a patch.

The if statement in that case is useless, the same logic apply to any kind of entity since we have the lid in the field data.

Patch updated. Thanks for reporting.

pinkonomy’s picture

Any thoughts why the Location CCK map doesn't appear when adding it to a panel?Thanks

garphy’s picture

Did you test again with the new patch. It could be related.

pinkonomy’s picture

Yes I tested against the new patch.After applying the patch I could set/save a marker on the map,but I couldn't add the map to a panel.

pinkonomy’s picture

@garphy could you take a look at the patch to see what's the mistake with that?Thank you

garphy’s picture

Mmmh. I have no experience with map/panels so I'm afraid I do not have any clue nor any testbed to address this issue. Is your test site publicly accessible so I can get an idea of the issue ?

pinkonomy’s picture

@garphy: Sorry,it only exists on my local host .
Has anyone else experience with maps and panels so as to solve this issue?
Thanks

garphy’s picture

Only for clarification : you do not have this kind of issue when the field is associated to a node entity ?

pinkonomy’s picture

When the field is associated with a node entity works as expected(Map appears in panels).The problem only exists when the field is associated with the USER entity.

pinkonomy’s picture

I think finally that is a ctools-page manager issue and not a Location cck field issue.Here is the corresponding issue on ctools: http://drupal.org/node/1197582#comment-5796846
It is a problem of appearing the forms.

n4te02’s picture

Thank you! garphy's patch worked like a charm :D

garphy’s picture

Glad to know.
What's missing to be ready to commit ?

scotwith1t’s picture

sorry garphy, not working for me. i had previously been using user locations, wanted to try out a patch working back towards a proper D7 entity field, but when i save the location_cck field, the values don't hold...i deleted the associated user location for that user and disabled the user locations module and it still doesn't hold the value of the cck location field. any suggestions? can't imagine how going through and deleting all the user locations i entered in testing would help...looking forward to that 5.x version too...location-based "stuff" is one of the biggest things keeping me from fully adopting D7 for new projects.

kevinquillen’s picture

scot.self, you can use AddressField + Geocoder + Geofield in the interim.

bnicoll’s picture

This worked for me - Thanks very much Garphy. Appreciate your hard work.

B.

garphy’s picture

@scot.self : I'm not sure that I correctly understood your point.

AFAIK, the patch doesn't relate to location_user but to be honnest I did not test location field provided by location_cck on user entities. I did test it on profile2 and some custom entities.

Maybe someone else could share its experience on user entities.

Aside scot, there's no negative feedback on the patch so far ?

Dadaisme’s picture

Assigned: ivanilic » Unassigned

Hi!

That bug is more like a critical thing to me!

I tried the patch #238 by garphy, works great. Will it be added to the next dev ?

Thx!

Note: I think that ivanlike made an error when assigning the task to himself...

polskikrol’s picture

Does patch #238 fix the issue of using Location CCK field under Account Settings 'Manage Fields'? I am experiencing the problem of required information provided during user registration not saving.

garphy’s picture

@polskikrol : IIRC this has not been fixed. I'm willing to fix it. I just need time to recreate the situation on a dev testbed.

Maybe I'm completely mistaken but what's the point of using location_cck for user entities ? Isn't location_user doing the job ? Remember that the 3.x release aim at being a D6-to-D7 port. Enhancements of location_cck (which should be renamed location_field) should be done in 5.x branch IMHO.

polskikrol’s picture

@garphy : Looks like location CCK is actually using fields though, as I do not even have CCK installed. Perhaps this should be renamed IDK. If there is some other method to be able to use location with users, please let me know as I have been hitting my head against a wall getting addresses to save when users add them during registration.

drupalina’s picture

I can confirm that the patch in #238 worked in so far as saving the Profile2 location field values and displaying the location address with a GoogleMap link. Thanks garphy!
However, the task in my project is to make that location appear automatically inside the Location block in the sidebar (as it did in 6.x), rather than simply print the address on user profile. I don't know if that's a Location issue or a GMap issue, but neither for nodes, nor for "profile2"s the Location Block with GMap is not displaying at all, whereas in 6x it did perfectly.

bkat’s picture

@garphy I don't know if this answers your question but I use location_cck to add an address to a profile2 entity. This is a d6 to d7 port replacing content profile with profile2.

pinkonomy’s picture

There is a new module that possibly saves maps with entities.Could someone check it please? http://drupal.org/project/google_map_field

fehin’s picture

FileSize
4.36 KB

Thank you garphy for your patch. The cck field I created on user account is saving the data. However I noticed something weird on the location_instance table. The user id is not saved under uid but saved under nid and vid. I'm trying to use views to filter users from a city but it doesn't return anything.

This is the query views returned;

<?php
SELECT DISTINCT users.uid AS uid, 'user' AS field_data_field_user_image_user_entity_type
FROM 
{users} users
LEFT JOIN {location_instance} location_instance ON users.uid = location_instance.uid
LEFT JOIN {location} location ON location_instance.lid = location.lid
WHERE (( (location.city LIKE 'New York' ESCAPE '\\') AND (users.status <> '0') ))
LIMIT 45 OFFSET 0
?>

location instance table

fehin’s picture

FileSize
6.09 KB

I enabled location on user account page and it looks fine on the location_instance table. I would use this setting instead of a cck field but it is not available on "Manage fields" page like other modules so I can't place it where I want on the form. I'm using Field group module and location is always either on top or at the bottom of the whole form. For example, contact, Time zone, User relationship are made available to the "Manage fields" page so I can move them to the position I want.

It would be nice if the option to display it on "Manage fields" page is made possible, so one won't feel the need to use a cck field. In the image below, lid 5 is the data from the location on user account settings page.

location instance table

scotwith1t’s picture

i agree, it wouldn't be necessary to have the separate module (which i realize was a direct port of the D6 version) if you could just have the user locations show up in the content type's fields! that's really the only reason i ever wanted to use location cck submodule in D7 anyway was for the location to be treated as a field. i'm going to try the geofield/openlayers approach this time and see what happens. good luck on the new version! will be keeping an eye on it!

garphy’s picture

I'll reroll the patch to fill the 'uid' column in case of a "cck" field on user entity. I think it will make your views query work.

garphy’s picture

Here's the new patch.

fehin’s picture

Hi garphy, thank you for the patch. I just tested it, the instance table looks the same. Still not saving the user uid.

garphy’s picture

Hi fehin.

Forgot to mention that it will not work with existing locations. Try to delete the location and fill it again. Hopefully, it will help.

fehin’s picture

FileSize
8.29 KB

I did that. I added two new location with different users. The lid are 7 and 8.

location instance table

garphy’s picture

Weird.
Anyway, my previous patch was missing a piece of the logic in location_cck_field_update(). Maybe it'll do the trick.

binabot’s picture

Title: Location CCK not saving for entities other than nodes » Location CCK field Patch

#105 patch works for me !!!!!!!!!!!!!! thanks a lot ! great work !

Alan D.’s picture

Title: Location CCK field Patch » Location CCK not saving for entities other than nodes

Reverting title.

"Location CCK field Patch" could refer to anything!

fehin’s picture

Hi garphy,
For some reason that small change you made in the patch in #269 stopped the data from saving. The cck location field is blank after you click on save and the data is not shown in the location table either.

jlongbottom’s picture

Location field in Profile2 not saving for me since upgrading to latest version.

fehin’s picture

Just wondering, isn't it better to get location to show under manage fields? User location saves data to the database the right way so I think it's better to focus on getting it to display on the managed fields page than spend time on cck fields. Or is it more difficult to implement? What hook does one need to make it happen? Most account and node data in D7 are made available to the manage fields page so I don't see why we shouldn't have this for location.

tribsel’s picture

I applied patch from #269, location fields in profile2 are now saved. However, province field gets messed up on save. I enter province name, save profile and what happens is that province name is being replaced with some strange number....

Funksmaname’s picture

I was using location inside a field collection and it wasn't saving field content - i can confirm patch #269 fixed this and now locations are being stored.

KorbenDallas’s picture

Awesome patch garphy! #269 is working for me. The standard location user module doesn't update user locations, but disabling the location user module and attaching a CCK field to the profile remedies that issue.

Thanks again

jamesbenison’s picture

OMG!!!

How much more mental masturabation has to take place on getting a physical location attached to an entity?

Almost 300 posts is absurd.

My issues queue has been reminding me for over a year that this still hasn't been figured out.

Most developers moved on long ago to other options. This thing is obsolete. Get over it.

jamesbenison’s picture

Let me say in a nicer way that better more powerful libraries with fantastic drupal integration are available.

fehin’s picture

I have found my way around the user cck field issue. I now use the user location field instead of cck. I modified my field group setting, adjusted location weight and it now fits in my registration form better. It saves properly thanks to #269 patch and no database issues.

fehin’s picture

@jamesbenison

Let me say in a nicer way that better more powerful libraries with fantastic drupal integration are available.

Like?

I tried to use Address field module but it wasn't as customizable and help wasn't forth coming. At least this issue is getting replies. Also I'm yet to find a reliable proximity search tutorial for Address field module and the other geocoding modules.

jamesbenison’s picture

I have been successfully using address field with geocoder and geofield. It is very flexible. I have not had any issues with getting support.

I haven't had to integrate it with a proximity search. But as long as you can get coordinates out of if I don't see any reason why it would be difficult.

The writer of the geofield library created the drupal module. Because everything is fieldable in drupal 7 it can be attached to anything and it works (unlike this module that was build to accommodate users and nodes). It can also be integrated with gmaps and with open layers. And since it works with things like drupal commerce you have a unified address storage solution for virtually anything (like drupal commerce). It also frees you up to extend your address with things like a dedicated phone field (for which a couple solutions are available).

Note that the above was all purpose written for drupal 7. If it doesn't do something people need then we can do code contributes to extend it. I just think it is a more appropriate place for further development. And the fact that this has not been resolved for over a year I believe proves that point.

Funksmaname’s picture

I spoke too soon in #276 - seems locations are still not stored if added on the main node edit page, only if you go directly to the individual field collection item edit page (that only shows that repetition of the group)

I will try the above advice to use address field with geocoder.

jamesbenison’s picture

The location and gmap modules have been positively stellar. I have personally used them many times over the years. I'm thankful to the guys that made them as are many others. But right now for this module to continue it needs to justify its existence.

Imagine if the last fifteen months worth of effort had instead been spent on things like a proximity search.

Data organization is absolutely positively key.

Your address and phone number is totally useless if it only makes sense in the context of your module.

Please don't hate on me. I'm just saying what needs to be said.

I have projects that warrant equal criticism. And I would not get mad if anyone decided to call me out.

garphy’s picture

FWIW I don't think there was so much effort on these past 15 months. Lots of yelling, complaints & requests. I submitted some patches because they solved issues on my projects and I was willing to help out.

We were used to location on D6 and it was doing a great job. I was hoping that 5.x would take on so we've stick a while on 3.x branch in the meantime.

But now, I think we're gonna look forward other D7 alternatives.

My patch seems to be incorrect or not perfectly accurate on every use cases but I have to admit I can't reproduce all that cases.

If there's no other people to help out polishing the patch, I think that it won't be commited ever and I suggest to use available time/energy either on 5.x branch or on other alternatives.

garphy’s picture

@jamesbenison : From my perspective it wasn't a 15 months effort. If it has been, I hope I would be able to finish 5.x instead of struggling with monkey patching.

Maintainers, please drive your project...

rooby’s picture

I am one of the co-maintainers.

I spent a lot of time on the original port to drupal 7 but I just don't have the amount of spare time required to get on top of an issue queue of this size + finishing a good quality port to 7. It's not really a one person task.

Location has always been purely a spare time task for me and I currently only have time to put into things that directly relate to my paid work.

I feel very bad about it because I've said I was going to do it but I just haven't been able to make the time.

From what I have seen of the other maintainers they are in the same boat. Either persuing other location based projects like geofield / addressfield / openlayers or just having no time.

I'm sure if there is anyone out there that wants to push this to the next level bdragon would give them commit access. I'd be happy to help out here and there but can't promise any decent quantities of time.

From my point of view, for my drupal 7 sites I have used geocoder, geofield, addressfield, field_collection, staticmap, open layers & custom google maps integration directly with the API.

I haven't come across anything yet that I haven't been able to do with those.

Things I have heard might be issues that I haven't investigated yet are:
* Issues with addressfield and required / not-required / hidden address parts. Not sure how it handles that but it is a flexible module so it shoudl be possible to do what you want.
* Proximity searching / filtering: Note sure if anything else has post code based proximity searching, although location just works of a big database of post code data, which could easily be done with any module.

One thing that shouldn't be ignored is the fact that there are a lot of people using location in drupal 6.
So from a data storage point of view, an upgrade path to something like geofield and/or addressfield, if it is possible would be great. - In the case that no one wants to take on the location beast. Or even maybe in addition to a new version of location.

jamesbenison’s picture

@rooby

You have no idea how much I respect you for manning up! Hold your head high!

Thank you for all of your hard work. It has not gone unappreciated. You are a great programmer and I know you will contribute much more in the future as you have in the past.

Let's move forward guys.

jamesbenison’s picture

I have migrated several sites from location to address field. It's not that hard using feeds.

Shadlington’s picture

If you use search api as your search module (generally in conjunction with views) then the module Search API Location theoretically does the trick of providing proximity search with geofield + addressfield.

Unfortunately, its not really working 100% and could probably do with a few people helping out in the issue queue.

Demo of it in action: http://spatial.mollux.be/spatialsearchview

rooby’s picture

Off topic
----------------------------------------

Thanks Jim.

There will definitely be much more contributing, it'll just be more spread out across different projects.

With the resources available I think it will be much more time effective to focus on helping make the new wave of geo modules great instead of rebuilding the old from the ground up.

Also, I know a lot of people are attached to the idea of a single module that does all your location stuff, but I've done a lot of thinking in the last 6 months about approaches for a new location module, and I keep coming back to a fieldable location entity, which uses geofield for storage along with some predefined fields for address data and some views integration. Users could then add their own fields for phone numbers etc.

And then I think... Why do we need a module for that when it's already available.
You can already create a "location" node type with a geofield and an address field (or individual text fields if it suits you better - or no additional fields if you only need geo).
You can use the field collection module to group multiple fields.
Then you can create views to do what you want with that data.
And you can use the entity reference module to link locations with other entities.
Or you can just add the fields directly to the target entity and not need entity reference for a simpler solution.

The geocoder module is a good geocoding solution to add to that for those who need it.
Proximity filtering in views is being worked on at #1360260: Add views filter to provide proximity search of Geofields and #1469956: [Meta] - Improve Views-powered Geofield proximity searches and other issues.
Proximity search with the location search api module.
Plus many more add on modules for things that location doesn't even do.

Some people say that now with entities you shouldn't be using nodes for things like this, but in my opinion drupal 7 isn't really ready for properly using non-node entities, so I don't think it is an issue.
For example, there is still no support for revisions via the entity api module (although a patch is getting close to being done), comments are still node specific (reply module is in the works), workflow module is node specific, along with heaps of other things that are still node specific.

So that's why I don't really think there is a need for the location module any more. We have progressed beyond its usefulness :)

All we need is an upgrade path out of here.

kevinquillen’s picture

Location is a perfect candidate for being an entity and not a node. There is just a lot of legwork to get it to that point. A Location field/widget/display would work (theoretically) on node types, users, taxonomy, profile2, any custom entity, it should just work without hardcoding anything and sticking within the entity.inc and entity API. I haven't looked at 5.x, maybe you're already going that route.

Edit: that is, for people who want to use Location for D7. The other formulas (Geofield, AddressField, OpenLayers, etc) are not as easy to setup for most people, but do work.

Alan D.’s picture

All valid points, but #1346746: Roadmap for next gen location (7.x-5.x) is the place for discussions about this. There are a lot of subscribers needing a solution to this issue and they are getting a lot of noise about un-related topics.

jamesbenison’s picture

Status: Needs review » Closed (won't fix)

I agree with rooby on #291. For folks that want to move beyond the limitations of the location/gmap modules I recommend people look there.

For those that would like to remain with the legacy approach #293 is where to look: #1346746: Roadmap for next gen location (7.x-5.x)

I disagree that these posts are unrelated. Declaring fulitility after 300 posts of trying to force the square location 7.x-3.x module into the round entity hole is as totally related as you can get. That is the conclusion that we have reached.

I'm closing this thread (won't fix).

Thanks again rooby!

PS: For storing revisions using a non node entity look at drupal commerce. It does exactly that with the product entities.

fehin’s picture

I'm sorry jamesbenison, but who made you the judge and executioner of this particular topic? We get it, you have found what works for you but some of us haven't. I have tried address module and it didn't fit what I need. I'm sure several people keeping coming back to this thread because they haven't found a solution with other modules. The other modules that have been recommended were also mentioned to not work properly for certain things just as this module isn't working perfectly for certain things. Some of us have no need for commerce module so recommending it does nothing for us. Had this thread not stayed open, someone wouldn't have posted the patch in #238, which works for the most part (Thanks garphy!). Until work on 5x starts, I don't see why this thread should be closed. If this thread bothers you so much, then pleas unsubscribe.

fehin’s picture

@Funksmaname, the patch in #238 works for nodes and user. The only issue is the user cck doesn't save properly in the instance table, I used the regular user location instead of cck and it saves the data properly. The patch in #269 for some reason doesn't work so try #238 instead.

Alan D.’s picture

Status: Closed (won't fix) » Needs work

@jamesbenison Please do not close a thread like this. It is frustrating that it is not resolved, but leaving it open allows users to see the limitations and issues that currently exist in the module; and in among the noise here, there is work being done on this issue.

I personally like a plug and play module that does everything in one hit, configuring up the alternative is possible, but these are complicated and (when I last tried) unstable outside of a narrow range of working parameters.

jamesbenison’s picture

Status: Needs work » Closed (won't fix)

IMO this should be closed. Folks that want to stick location can go to the 7.x-5.x thread. The latest development is going into the geophp approach.

Thread#295...
I am not trying to be an A (albiet I'm doing a fantastic job), but it isn't realistic to continue developing code for a branch simply because that's the only one that you know how to use. Get off your A and learn how to use other options.

If you want to keep this open then submit the ultimate uber patch that will fix this issue. Otherwise you have no leg to stand on.

If you are new I am always happy to do what I can to help you understand drupal better.

scotwith1t’s picture

Priority: Major » Normal
Status: Closed (won't fix) » Needs review

This should remain open for the reasons Alan D. mentioned. Plus there's a viable patch people are reporting works for them. Closing as Closed (won't fix) insinuates 1) That this is your module and you're maintaining the issue queue (don't think that's the case) and 2) You (as a maintainer of this specific module, which you are not) have no plans to fix this issue. There ARE plans to fix in the 5.x branch and, again, a patch here to get most some success. Thanks.

p.s. I can also add to those who confirm the patch works. Thanks Garphy!

chrbak’s picture

Patch #238 worked fine for me. I am using location CCK with profile2..

Thanks very much Garphy.

aniebel’s picture

I'm puzzled. The latest 7x-3.x-dev location_cck.module is not the same as #238. Hard to patch when lines aren't matching up, no?

garphy’s picture

I'm puzzled. The latest 7x-3.x-dev location_cck.module is not the same as #238. Hard to patch when lines aren't matching up, no?

Well, it must be that the repository has received commits after the rolling of the patch. I've no time to re-roll it right away but I hope I can do it soon.

aniebel’s picture

Sorry, that wasn't a comment directed at you. I must not understand versions. I'd have thought that if there were new commits to 7.x-3.x-dev, the version would change slightly. That way, it would be clear that the version you patched is still intact. Thanks for replying and your help!

garphy’s picture

AFAIK, this is common practice to submit patch against -dev, which in turn is an ever changing code base.

Patching against -dev allows maintainers to integrate it more easily but as a result, the patch has to be kept in sync with de current code base.

As you may have noticed, this issue is drowning as there is different point of view on the way this should be addressed and, moreover, if it should be addressed at all.

jghyde’s picture

Patch #238 fixed my issue.

User story: As an authenticated user, if I add or update the profile location field, Drupal does not save the location into the user object.

After applying the patch, location information is saved in the profile field.

Using plain 'ol Profile.

Joe

DamienMcKenna’s picture

I've tweaked the patch from #238 to fix a few small coding standards violations, it's still all garphy's work.

DamienMcKenna’s picture

Priority: Normal » Major

Just to throw in a few thoughts..

There are two issues being discussed here.

The first, and most pressing issue, is making Location_CCK work with all entities as-is. When you install the module there's *nothing* stopping you from adding a location field to any fieldable entity in the system. The problem, and the reason for this bug issue, is that it only saves data for fields added to nodes, i.e. this is a data-loss bug that warrants a priority change to "major" (as I've just done). The patch in #238 appears to resolve this problem quite successfully and has several people saying it works great for them (my patch in #306 just cleans up the code slightly). This should be committed so the next 7.x-3.x release works the way everyone expects it to.

The second issue is a rewrite of Location to be cleaner, i.e. an entity system unto itself; that is the focus of the 7.x-5.x branch and what goes on there should not stop this important bug fix from being committed.

DamienMcKenna’s picture

FileSize
3.54 KB

Another slight syntax improvement, I collapsed two else{if(){}} blocks to keep the code simpler.

ebeyrent’s picture

Status: Needs review » Needs work
+++ b/contrib/location_cck/location_cck.module
@@ -163,6 +163,16 @@ function location_cck_field_insert($entity_type, $entity, $field, $instance, $la
+  elseif (!empty($items)) {
+    list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
+    // Store instances of locations by field name and vid.
+    $criteria = array(
+      'genid' => 'field:' . $field['field_name'] . ':' . $entity_type . ':' . $id,
+      'vid' => $vid ? $vid : $id,
+      'nid' => $id,
+    );
+    location_save_locations($items, $criteria);
+  }

This code is repeated a few times in the patch - should be in a function?

RainbowArray’s picture

I just applied the patch in #308 to beta1, and it worked just fine. Location data is saving correctly when attached to a field collection. Huzzah!

IWasBornToWin’s picture

I just applied latest patch and now it saves for user fields...thanks. I do not see this field with all my other user fields in rules?

rooby’s picture

Status: Needs work » Fixed

Thanks to all for your efforts and perserverence. Sorry it took so long but #308 is comitted.
http://drupalcode.org/project/location.git/commit/81ea777

@ebeyrent:
In this case I don't think it matters too much for now.

+++ b/contrib/location_cck/location_cck.module
@@ -163,6 +163,16 @@ function location_cck_field_insert($entity_type, $entity, $field, $instance, $la
+  elseif (!empty($items)) {
+    list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
+    // Store instances of locations by field name and vid.
+    $criteria = array(
+      'genid' => 'field:' . $field['field_name'] . ':' . $entity_type . ':' . $id,
+      'vid' => $vid ? $vid : $id,
+      'nid' => $id,
+    );
+    location_save_locations($items, $criteria);
+  }

In addition, I don't really like that these parts handle nodes differently to all other entity types. So I will look at a follow up to make it the same for all entities, with appropriate update functions etc.

Any follow ups in new tickets please so we can close this beast.

I will create an alpha release, tidy up a few other key issues like token support and then create a beta.

scotwith1t’s picture

@rooby, that's GREAT news. Could you update the project page to reflect? Looking forward to trying this out.

rooby’s picture

I have updated the whole section regarding Drupal 7 versions to reflect the current state of things.

Status: Fixed » Closed (fixed)
Issue tags: -Needs issue summary update, -profile2, -location user

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

diegops’s picture

Issue summary: View changes

in my case it wasn't working because it had two field locations on user page..one by default and one added by me...removed the default and it worked.