i've been making heavy use of the location.module for a new 4.6 site i'm building. i love it. one slightly annoying problem i've encountered is that there seems to be no way to control the weight of the location box. it always appears at the very bottom (weight 20 or something) of any given node. for various reasons, i've defined a flexinode called "place" that i use for all my locations. unfortunately, any additional fields i add to this flexinode (note, URL, phone number, etc) always appear before the location itself, no matter how heavy or light i make them. obviously, i'd like the location info to be the first thing you see when viewing a "place". am i missing something, or is there really no way to control this? all other fields in a flexinode have their own weight. this seems like a natural thing for location.module to provide.

if i have a chance, i'll take a stab at a patch for this and submit it. in the meantime, i'm curious if other people:

  • know of a way to accomplish this given the current 4.6 codebase
  • if not, think this would be a valuable addition to location.module

thanks!
-derek

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

KarenS’s picture

+1 on this idea, I needed it, too. I found a way to do it in 4.7 but am not sure it can be done in 4.6, at least I can't figure out how. It looks to me like 4.6 doesn't use "weights" for form elements, but 4.7 does. In the absence of some sort of weight, things end up in the order they are processed or the order in which various modules touched them.

Anyway, if anyone else is interested in this feature for 4.7 I'd be glad to provide my changes. While I was at it I added an option to say whether or not to display the form as a collapsible fieldset and to select whether or not to default it to the collapsed state. These setup options all get displayed in the same box where you enable various node types for locative features.

dww’s picture

Version: 4.6.x-1.x-dev » 6.x-3.x-dev

yes, it seems like the forms API in 4.7 will mostly solve this problem. i'm moving this issue's version from 4.6 -> cvs. if you've got patches to location.module that add the weight, collapsable fields, etc, i think you should definitely post them here, and we should get them into the 4.7 location asap. thanks!

-derek

KarenS’s picture

FileSize
2.77 KB

Here's a patch. It's the first time I've tried creating a patch so hopefully I got it right :-)

Also, just to be clear, this will change the placement of the location box in input forms (when adding or editing a node) but won't have any affect on the display when viewing the record.

KarenS’s picture

FileSize
2.76 KB

Oops -- slight mistake. The weight was supposed to default to 0. Here is an updated patch.

ankur’s picture

FileSize
3.85 KB

Thank you KarenS,

Committed a slightly altered version of the previous patch. I changed it a little so that the default values for collapsible and collapsed are true. I also changed around the printing of the lat/lon message when a user has permissions to submit for a lat/lon. A copy of the resulting patch is attached.

Will leave this issue open for now, however, because the issue was originally about changing the weight of locations for node views. I know that this isn't as possible for 4.6, but cannot confirm the same for 4.7. Will leave the issue open until we can make sure whether or not display weights can be altered.

-Ankur

ankur’s picture

so, does anyone have any idea about whether it is possible to control the weight of a location in a node view for 4.7?

If not, I'll have to close this issue.

I haven't mentioned in this issue yet, but if you turn off the display of locations in admin/settings/location (just the display), it is possible to decide how locations get displayed w/ your own theme (at least in phptemplate, not sure about other theme engines). The node object that is passed has the entire location at $node->location after you set $node w/ a call to node_load(). This generally happens in the module code, not the theme code, but is available for the theme code to use after the it has been loaded by core/module code.

This means that, not only can you control the CSS of the location that is output, but you can also control the how and where actual HTML gets output within the node view (or a user view if you're trying to theme it to a different location).

-Ankur

geodaniel’s picture

This is also relevant for 5.x (current HEAD) except now the location information box is at the top of the page instead of at the bottom when viewing nodes.

jiangxijay’s picture

I wish to have the location fields appear at the bottom of node content, too, but the description of what to add via phptemplate theming is beyond me ;)

Has anyone else resolved this?

manerhabe’s picture

I also would like to find a way to move the location information below the body of the node if possible without hacking some PHP. :)

rtdean93’s picture

I too would like to move the location to the bottom of the node view.

scottrigby’s picture

subscribe

manerhabe’s picture

Strange... when I added a text box field with CCK to my event content type (which I have the events & location modules enabled for), the location box mysteriously moved to the bottom. If I goto Manage fields in Content types, it lists the location box with a weight of 9. However, if I delete the text box field, the location box goes back up top.

scottrigby’s picture

my solution for now is to print the locative information when and where I want using my node-(content-type).tpl.php
I'm not great at this -- code is extremely messy (so if there's a better way to do it - pleas let me know!). But it's working for me, and it seems others are having trouble.
So in case my code (or responses by others who can better advise how to write this) could be helpful to someone else, here it is:

<div class="location-display">
  <h2>Location</h2>
    <!-- comment out, so I can add only what I want -->
    <!--<?php print theme('location', $location); ?>-->
  <!--<?php if ($location['name']) : ?>
     <?php print $location['name'] ?><br />
  <?php endif; ?>-->
  <strong>Address:</strong><br />
  <?php if ($location['street']) : ?>
     <?php print $location['street'] ?><br />
  <?php endif; ?>
  <?php if ($location['additional']) : ?>
     <?php print $location['additional'] ?><br />
  <?php endif; ?>
  <?php
  $citystate = ($location['city'] ? $location['city'] .', ' : '') .  ($location['province'] ? $location['province'] .'   ' : '') . $location['postal_code']; ?>
  <?php if ($citystate) : ?>
     <?php print $citystate ?><br />
  <?php endif; ?><br />
  <!-- comment out country because this particular site is only in the us -->
  <!--<?php if ($location['country']) : ?>
     <?php print $location['country'] ?><br />
  <?php endif; ?>-->
  <?php $maplink = location_map_link($location, '<strong>Directions: </strong>');  ?>
  <?php if ($maplink) : ?>
     <?php print $maplink ?>
  <?php endif; ?>
</div><!-- end location-display --> 


<div class="rest-phone">
<strong>Phone: </strong>
<?php 
print $node->locations[0]['phone'];
/*print $location['phone'];*/ /*another way of writing this apparently?*/
?>
</div>
bdragon’s picture

Title: defining the weight of the location box for each node? » [master] defining the weight of the location box for each node?
Version: 6.x-3.x-dev » 5.x-1.x-dev
Assigned: Unassigned » bdragon

(marking master)
(http://drupal.org/node/180035 marked duplicate)
(http://drupal.org/node/171111 marked duplicate)

There are two issues here.

First of all, the location fieldset needs to have a weight, and there needs to be an easy way to configure it.

Second, location needs to use the $node->content array (Note: The latest DRUPAL-5 currently does this, I am not sure if any actual release incorporates this change though)

bdragon’s picture

Title: [master] defining the weight of the location box for each node? » [master] Location weight on edit and display

(Generalizing topic)
(http://drupal.org/node/153891 marked duplicate (Issue has possibly relevant patch))
(http://drupal.org/node/155439 marked duplicate)
(http://drupal.org/node/137820 marked duplicate)
(http://drupal.org/node/194900 marked duplicate)

This also affects profiles.

bdragon’s picture

crocodyl’s picture

I am not sure what the solution is. Should I install a patch? Anyone know which one is best? Also, does anyone know where a set of instructions on how to install a patch is?

chlobe’s picture

subscribing

nicholasThompson’s picture

anthonym’s picture

FileSize
29.51 KB
41.57 KB

I've been having trouble with the position of the location info in my created content type for a while now. Just installed the latest HEAD release, hoping this might make things better, but I'm still getting the same results. I have the weight set correctly in the content type>edit tab (i.e. highest number = lowest position, but the location info is not behaving as expected. Instead of appearing last as defined, the location info is appearing second. Screenshots below. Where should I look to troubleshoot this?

anthonym’s picture

Category: feature » bug

Changing category to bug report since this doesn't appear to be working correctly, at least for me.

mcurry’s picture

Version: 5.x-1.x-dev » 5.x-2.7

subscribing.

I just had to do a hand-patch to fix this in 5.x-2.7. Is there a formal patch for 5.x-2.7?


--- location.module	2007-08-22 18:09:16.000000000 -0700
+++ location.module-patched	2008-05-04 00:25:47.000000000 -0700
@@ -1059,28 +1059,31 @@
   
             }
           }
           
           if ($output = theme('locations', $posted_locations, variable_get('location_suppress_country', 0) ? array('country') : array())) {
             $node->content['locations']['#value'] .= $output;
+            $node->content['locations']['#weight'] = variable_get('location_weight_'. $node->type, 9);
           }          
         }
         else {
           if ($themed_locations = theme('locations', $node->locations, variable_get('location_suppress_country', 0) ? array('country') : array())) {
             $node->content['locations']['#value'] .= $themed_locations;
+            $node->content['locations']['#weight'] = variable_get('location_weight_'. $node->type, 9);
           }
           
           
           //if (!$teaser) {
             //drupal_set_html_head(location_geocode_meta_tags($node->location));
           //}
         }
       }
 
       if (variable_get('location_addanother_'. $node->type, 0) && count($node->locations) < variable_get('location_maxnum_'. $node->type, 0) && !$teaser && node_access('update', $node)) {
         $node->content['locations']['#value'] .= drupal_get_form('location_extra_form', $node);
+        $node->content['locations']['#weight'] = variable_get('location_weight_'. $node->type, 9);
       }
       break;
 
     case 'rss item':
       $items = array();
       if (is_array($node->locations)) {

bdragon’s picture

Status: Active » Closed (won't fix)

Wontfix for 2.7, 3.x allows setting weight in the configuration.

dww’s picture

Cool, thanks. ;) Shouldn't we call this "fixed" in 5.x-3.x-dev then? It's your queue, so I leave it up to you, but I personally prefer "fixed" when I actually fix something.

rootwork’s picture

Status: Closed (won't fix) » Active
FileSize
59.29 KB

So...I'm using the 3.x RC2 version in D6, and I don't see anything on the configuration pages to allow for setting weight. Is there something I'm missing?

I don't know if this applies to the D5 version as well, but I assume both 3.x versions would have the same configuration screens.

lyricnz’s picture

Status: Active » Closed (won't fix)
FileSize
123.31 KB

This configuration is in each of the places where you enable Location module, not in the Location settings (this is so you can configure it different in different places).

Eg: when editing the content-type, or the user-settings. See attachment for example of Story content type.

YesCT’s picture