Pro & cons of using Core Location vs. Location CCK

CMSjunkie's picture

I'm just learning Location and I have noticed that both core Location fields and Location CCK "can be" available to CCK.

1) Is one better to use than the other and why have two, since core Location fields are available to use in CCK (edit) and Location CCK is available via manage fields, if enabled of course

2) Can either of these be configured to also be Tax Terms?

3) Do both versions work with the "Node Locations" block?

Login to post comments

some differences...

bec - Mon, 2009-06-08 16:13
  • "core" location fields have been separated out into the "node_location" module, which is included in the location package. This way you can choose to have only one type on your site.
  • Only locations added with node_location work with the "Node Locations" block.
  • CCK Locations in Views require a relationship.

Legacy vs. New-way

phayes's picture
phayes - Mon, 2009-06-08 16:16

The basic difference is that core location fields are the 'legacy' way of storing locations, and the cck is the 'up-and-coming' method.

Given the state of most modules at this point it might be best for you to stick with the core location fields - although that is changing rapidly.

Myself, I would go with cck (as this is where everything is going in the future), and contribute code to projects that needs to move from core to cck. But if you are not a coder, then core fields is likely your best bet.

Cheers,

Patrick


thanks for replies

CMSjunkie's picture
CMSjunkie - Wed, 2009-06-10 04:34

well since this is a new site, sounds like location CCK might be the best choice

or.... will I be able to import into CCK later?

Turning Location CCK is easy enough

But how do I disable the native or core location features - so I don't see two?


hit 'edit' on the content

phayes's picture
phayes - Wed, 2009-06-10 06:04

hit 'edit' on the content type and set the number of location fields to zero


To turn off legacy-style

bec - Wed, 2009-06-10 16:24

To turn off legacy-style locations, you should disable the "Node Locations" module on your modules page.

AttachmentSize
location modules.png 102.66 KB

What about users?

raintonr's picture
raintonr - Thu, 2009-06-11 02:47

This is interesting. I've been tinkering with this and using content_profile with location_cck as a way to store a users location.

It seemed like a good idea at the time ;)

What does everyone think of that?


For now and the future I

derhasi's picture
derhasi - Thu, 2009-06-11 22:13

For now and the future I would definitely propose using location_CCK. Besides the fact, that with any user, testing the module it will come to a fully featured method for storing Geographic data much faster, i'd propose CCK because of its broader point of view.

Some features core locations do NOT have are:

  • using revisions
  • using different location types by using different fields
  • using different formatters (writing a new formatter for cck is quite easy)
  • prepares for the Drupal-7-fields-in-core-point-of-view

Sure, using location_cck with content profile is a good solution.

Another general hint for using a GMAP output within a node in D6: Views Attach - really nice Views Plugin, with opportunity to weight the specific views, like fields for node view.

What's missing for location_cck mght be some additional widgets and formatters, I hope to provide some for that in the future, but cannot promise.


User location

mErilainen's picture
mErilainen - Thu, 2009-06-25 13:57

I guess there is no way to attach a CCK field to a user? User locations provide a possibility to calculate distance from current user's location to a node, but is it possible to calculate it to a CCK field or the other way around? Even better if a CCK field could be assigned as user's location, because then it could be attached to a profile node. I don't want my users to add some of their locations here and others there.


check out Content Profile module

Chris Einkauf's picture
Chris Einkauf - Thu, 2009-07-02 23:17

I'm pretty sure the best way to assign cck fields to users is via the Content Profile module. You'd use this as opposed to using the core ("core - optional") Profile module. With Content Profile module, you can use any cck field that you want (including Location CCK), plus there's an included module that allows you to have the user fill out their profile fields right when they initially register for your site.


Is already in use

mErilainen's picture
mErilainen - Thu, 2009-07-09 07:00

Of course I'm using Content Profile, I think that's the only way to go for flexible user profiles.

But using Location CCK fields, I can add multiple location fields to CP. The question is, how to assign one of those fields to user's account (=user's current location). Because when I used Location module with User Location sub-module, there was an option to use e.g. distance field with Views. Now I can only use a distance to some fixed location, because Views (or Location module to be exact) cannot say what is user's current location where to calculate the distance to.


No, there is no built-in way

bec - Thu, 2009-07-09 14:15

No, there is no built-in way to use a CCK field with Content Profile to set the user's location the same way it is set using the User Locations module.

Programatically, you can save a user location with:

<?php
location_save_locations
($array_of_locations, array('uid' => $account->uid));
?>

Then, if you have the User Locations module turned on, these locations will be used as user locations. See the implementation of hook_user() in location_user.module.


Hide fields from user

mErilainen's picture
mErilainen - Mon, 2009-07-13 10:22

That sounds possible, if I use CCK field to collect user location and then save it with that function. Then I just have to hide the fields which User Location module will show. Does this sound reasonable?

Anyway, if Location module is going towards using CCK fields, there should be a way for user to choose current location and then User Location module can be disabled completely.


Can I use an argument or token to get proximity to profile node?

strellman's picture
strellman - Tue, 2009-07-14 16:27

I'm not sure where or how to use that snippet. I'm also leery of maintaining this over time.
Is there another way to get proximity working for content profile? I want to be able to show the user other users within a given radius. The proximity field and filter depend on the user location. The location map block just shows the user where he is, which he already knows.


I am trying to get the same

sagannotcarl's picture
sagannotcarl - Mon, 2009-08-03 01:25

I am trying to get the same thing going. There is some useful info here: http://drupal.org/node/334846#comment-1582112 but I haven't gotten it fully working yet. Let me know if you figure it out!


Location_cck & views attach

drew reece - Fri, 2009-06-12 17:46

derhasi, I'm interested in using views attach to bring the location cck field in as a gmap, but it doesn't seem feasible.

I have a 'node content' type view that displays styled as a Gmap. It uses a relationship to gat the latitude/longitude fields from the location_cck feild. The views attachment shows all nodes that have a location. I can't seem to get the current node id to restrict the results to just the current node. Any ideas?

I understand the logic behind using location_cck over node_locations but is it actually possible to show the map on a node?

I'm using
Location 6.x-3.1-rc1
GMap 6.x-1.1-rc1
GMap Location 6.x-1.1-rc1
Views attach 6.x-2.0


You can restrict the view to

derhasi's picture
derhasi - Fri, 2009-06-12 18:08

You can restrict the view to the current node by using the Views-Argument by two ways:

  1. When token.module is installed:

    • set Default argument in the Node content settings (below the general views settings) to [nid]
  2. Using a the default argument within Argument Node: Node-ID

    • select Provide default argument
    • then select Node-ID from URL

Thank you

drew reece - Fri, 2009-06-12 19:41

I have done what you described in 1 & 2, but only 2 seems to work.
Method 1 still shows all location_cck fields.

I was using both options (after much experimenting) so it's good to know only the Node:Nid view argument is actually required.

Incidentally, I needed to add some patches to get this far, the modules are listed in my above post. I added these patches.

Token data not passed to argument comment #60
Array errors in location_cck module comment #5

It seems that location_cck is still very early days.

Thanks again.


templates can't access fields from within location_cck

3goose - Mon, 2009-06-15 19:39

When i'm building custom templates, i can't seem to pull only a portion of the information from the location_cck field. Using core location, i was able to access individual portions of the address, such as only the city in this example:

<?php
print $fields['city']->content;
?>

But using similar methods with location_cck seem fruitless. If i show all fields with print_r($node) in the node template, for example, the location_cck field is always one monolithic field.

Does anyone know of a way to pull only one "field" from the location_cck "field"? (i'm not sure here which should be called a field.)

If this is a limitation in location_cck, can this be addressed? (AKA, can i pay someone to fix it without a serious rewrite?)

If not, it's a total deal breaker for me.


Any reason for not using views?

drew reece - Mon, 2009-06-15 20:26

Views 2 seems to be able to pull out customized fields from location_cck then it's a case of printing the result. Forgive me if I'm misunderstanding.

You may have better luck searching & posting in the issue queue for Location.


I can access parts of a

bec - Tue, 2009-06-16 01:36

I can access parts of a Location CCK field just fine in my node templates; the complete location data is in the field variable. If my CCK field is called "field_my_location"; in my node template, the $field_my_location variable looks like this:

<?php
Array
(
  [
0] => Array
    (
      [
lid] => 2
     
[name] =>
      [
street] => 2135 W North Ave
     
[additional] =>
      [
city] => Chicago
     
[province] => IL
     
[postal_code] =>
      [
country] => us
     
[latitude] => 41.910403
     
[longitude] => -87.681302
     
[source] => 3
     
[is_primary] => 0
     
[province_name] => Illinois
     
[country_name] => United States
     
[view] => <div ...
    )
)
?>

Just be sure to check_plain() the values (other than $field_my_location['view']) before you use them, since the individual bits aren't sanitized.

... or maybe you're trying to access locations somewhere else in the theme system... if so, where?


Spotty luck

3goose - Wed, 2009-07-01 04:52

I redesigned the node in question and did get access to the individual fields, but now have another node that is
exhibiting the same bad behavior. In the node template, this code:

    
<?php
print_r
($field_loc)
?>

produces this output, with none of the individual fields accessible.

<?php
Array
(
    [
0] => Array
        (
            [
lid] => 692
           
[view] =>
2222 Main St.
Denver, CO, 80205
United States
39° 45
' 23.9796" N, 104° 58' 52.8852" W
        )
)
?>

Does anyone know what I'm doing wrong, or what location_cck is doing wrong?


Maybe using the wrong variable with print_r

Chris Einkauf's picture
Chris Einkauf - Thu, 2009-07-02 23:54

Instead of using...

print_r($field_loc)

you might want to try using

print_r($form) // if it's for the node input form

or

print_r($node) // if it's for the node display

This is just a guess (I'm not using Location CCK as of right now), but some other fields in one of those two variables ($form or $node) might be the actual source of the information in the $field_loc variable


I'm in a node template

3goose - Mon, 2009-07-06 15:23

Thanks eink21, but I'm printing from a node template, and got the field name from doing a print_r on the node array. I'm stumped.


It's working for me

Chris Einkauf's picture
Chris Einkauf - Tue, 2009-07-07 17:14

When I do a print_r on the location cck variable ("field_company_address" for me), I get the following...

Array
(
    [0] => Array
        (
            [lid] => 10
            [name] =>
            [street] => 132 East Main Street
            [additional] =>
            [city] => Newark
            [province] => DE
            [postal_code] => 19711
            [country] => us
            [latitude] => 39.684009
            [longitude] => -75.747907
            [source] => 3
            [is_primary] => 0
            [province_name] => Delaware
            [country_name] => United States
            [view] => <div class="location vcard"><div class="adr">
<div class="street-address">132 East Main Street</div>
<span class="locality">Newark</span>, <span class="region">DE</span>, <span class="postal-code">19711</span><div class="country-name">United States</div>
<span class="geo"><abbr class="latitude" title="39.684009">39° 41' 2.4324" N</abbr>, <abbr class="longitude" title="-75.747907">75° 44' 52.4652" W</abbr></span>
</div></div>
See map: <a href="http://maps.google.com?q=39.684009+-75.747907+%28132+East+Main+Street%2C+Newark%2C+DE%2C+19711%2C+us%29">Google Maps</a>
        )

)

So it appears to be working for me at least. No clue what the problem might be for you, but here are some things I'd try if I were you (I know they look too simple to work but I'm out of guesses pretty much...)

-Maybe it's an incompatibility or adjusted setting for the Gmap module or whatever other mapping/location/geocoding module you're using. (I noticed the coordinates in your output. On your input form, do you actually have individual location fields, or do you just have the user click on the map and the map generates an address for you?)
-Similar to the last point, maybe your geocoding program takes the address information, assigns it an exact set of coordinates, then simply stores all of the individual address fields together in one big field. Maybe if you deactivated whatever geocoding module/software you're using, the individual fields would show back up.
-Check the settings for that field (in the "Manage Fields" tab for that content type). You might've checked some of the boxes that prevent the fields from being displayed on the node output.
-Check your permissions
-Clear your cache
-Check any customizations you made to any location-related core/contributed modules
-Install devel module and do a dprint_r($field_loc) instead of just a print_r
-Also with devel, check under the "dev load" or "dev render" tabs to see if the individual fields are showing up there
-For this particular node template, did you disable or set the #access to 0 for these location fields?

Again... just a bunch of random ideas. I'm obviously no expert, but I figured I'd try to at least help a little.


Finally got it!

3goose - Wed, 2009-07-08 19:52

My location module was up-to-date according to update status. But, I deleted location module, reinstalled it from a fresh download, ran update.php, and suddenly everything worked! Thanks for the help - I was getting really frustrated!


Drupal v6.13 Location Nodes

NewBee - Mon, 2009-08-10 16:58

Drupal v6.13
Location Nodes v6.x-3.1-rc1

Node Locations works perfectly, too perfectly for me ... I need Node location for a content (working right!) but i can't get rid of a 'Location form' ('Emplacement' in french , with address , country ...etc.. fields) on user registration (except by disabling the 'Node Locations' module :( . Please, any tip or suggestion is warmly welcome ...

AttachmentSize
howtoDisableLocationFormOnUserRegistration.jpg 70.26 KB

Re: Drupal 6.13 Location Nodes

NewBee - Mon, 2009-08-10 17:38

the magic came from /admin/content/node-type/profile (beware uprofile too ;) , everything is working fine , sorry for any inconvenience


Displaying locations of different nodes with Views/CCK/Location

pixelmord's picture
pixelmord - Thu, 2009-08-20 12:45

Hi All,

reading this thread and a lot of related informations and videos, I finally managed to have maps that partially suit my needs.
I'm using CCK, Location(used as CCK-field) and Views to get:

  1. A map view with all contents 2 content types( "organization" and "projects")
  2. A map attached to a node (of type "organisation") showing a single location of the node's address and also the locations of the projects that are attached to the organisation via node-reference and views-attach

For the first goal, I set up a view with a map display, a relationship to the CCK-field holding the location data of content-type01("organization"), the fields longitude and latitude coming from that relationship (used as data for the markers of the map).
That is working, but how do I get the data from the other content-type02("project") to be shown on the map also?
Can I somehow use 2 relationships and how can I make the configuration options of the GMap-display understand to use all the Lat/long-values no matter from which content-type they come from, like it is done with the Node-Locations-Page of the Location.module?

For the second goal, I set up a view with a display of "node content" to be attached to nodes of type "organisation", with a map display of the fields Lat/Long coming out of the relationship to the CCK-field, similar to the above, but with an argument set to Node-ID.
That also works, but now how can I see the locations of the related projects?(that are attached via the node-reference-field to the organisation)
Can I work with another view and then use the same map by assigning it the same ID via the GMap-Macro?