http://drupal.org/node/387900 - This is an old issue from Location Views. However, it is still an important one. If there is no province or city entered for a location, either because the person forgot or the country doesn't have provinces, Location Views puts the word Unknown as the link and you can no longer drill down to the next level.

What I propose instead is a way to make the blank default to All so that the level can be bypassed.

Comments

lonehorseend’s picture

I found a fix that seems to work. We need to trigger the wildcard in views to create the necessary link to the necessary level, but without forcing it do it in all cases by setting that parameter in the argument. So what I did was create a views summary override template file called views-view-summary--location-directory--page-1.tpl.php. The functionality of this template comes from views/theme/views-view-summary.tpl.php with the addition of an if statement that replaces the unknown text with the country name and adds all to the link.

<div class="item-list">
  <ul class="views-summary">
  <?php foreach ($rows as $id => $row): ?>
   <?php //The additional if
   if ($row->link == "Unknown")
  {
	$row->url = $row->url."all/";
	$row->link = location_country_name(arg(2)); 
  } ?>
<?php 
    <li><a href="<?php print $row->url; ?>"<?php print !empty($classes[$id]) ? ' class="'. $classes[$id] .'"' : ''; ?>><?php print $row->link; ?></a>
      <?php if (!empty($options['count'])): ?>
        (<?php print $row->count?>)
      <?php endif; ?>
    </li>
  <?php endforeach; ?>
  </ul>
</div>

Notes

  • The arg number is whatever your country arg is. In my case it is 2 because I have a couple of additional args in front of the country. Most likely yours will be 0.
  • In theory, if you have a province, but no city you would change the if statement to go after the province. In fact, you probably could refine the if statement to make the distinction between city and province levels, so country was used for the province level and province was used for city level
  • The issue was originally reported at http://drupal.org/node/387900
leahmd’s picture

Thanks for posting this, it was a massive help for me.

In D7 this is still an issue, in a case where there is a phone number but no street address, due to it being a social club/group manager.

I opted to skip the Unknowns in the directory listing entirely with a small modification of the above:

<div class="item-list">
  <ul class="views-summary">
  <?php foreach ($rows as $id => $row): ?>
       <?php //The additional if
       if ($row->link == "Unknown")
      {
        continue; 
      } ?>
<li><a href="<?php print $row->url; ?>"<?php print !empty($row_classes[$id]) ? ' class="'. $row_classes[$id] .'"' : ''; ?>><?php print $row->link; ?></a>
      <?php if (!empty($options['count'])): ?>
        (<?php print $row->count;?>)
      <?php endif; ?>
    </li>
  <?php endforeach; ?>
  </ul>
</div>

I hope someone finds this useful as I did the code above. :)

KingSalibah’s picture

I have this problem in D7 as well.

legolasbo’s picture

Issue summary: View changes
Status: Active » Closed (outdated)

Closing old D6 issues as D6 is end of life