*

morfik

  • ****
  • 169 posts
Cities in Popular locations in the theme footer
« on: March 04, 2023, 11:37:35 AM »
By default the theme footer displays Regions in the Popular locations.  In Poland we have only 16 regions. Is there a possibility to change items shown in Popular locations to cities and set their limit to some reasonable value?

*

MB Themes

Re: Cities in Popular locations in the theme footer
« Reply #1 on: March 07, 2023, 01:14:19 PM »
@morfik
Similar topics were discussed across different themes.
It's about changing model to CityStats and do few other adjustements.

Check i.e.:
https://forums.osclasspoint.com/osclass/show-only-10-items/msg37826/#msg37826
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

Marked as best answer by frosticek on March 08, 2023, 12:45:18 PM
*

morfik

  • ****
  • 169 posts
Re: Cities in Popular locations in the theme footer
« Reply #2 on: March 07, 2023, 06:29:12 PM »
Yes, that indeed solved my problem. :)

For those who also want more/different locations in the footer, go to oc-content/themes/delta/footer.php , and find the following section:

Code: [Select]
<div class="box b2">
        <h4><?php _e('Popular locations''delta'); ?></h4>

And replace the following code:

Code: [Select]
        <?php
          $regions 
RegionStats::newInstance()->listRegions('%%%%''>''i_num_items DESC');
          
$i 1;
        
?>

with this one:

Code: [Select]
<?php if (osc_count_list_countries()== && osc_count_list_regions() > 1) { ?>
<?php View::newInstance()->_exportVariableToView('list_cities'CityStats::newInstance()->listCities(""">""items DESC")); ?>


and also replace the following code:

Code: [Select]
          <?php if(is_array($regions) && count($regions) > 0) { ?>
            <?php foreach($regions as $r) { ?>
              <?php if($i <= 10) { ?>
                <li><a href="<?php echo osc_search_url(array('page' => 'search''sRegion' => $r['pk_i_id']));?>"><?php echo $r['s_name']; ?></a></li>
                <?php $i++; ?>
              <?php ?>
            <?php ?>
          <?php ?>

with this one:

Code: [Select]
        <?php $i 1?>
  <?php while(osc_has_list_cities()) { ?>
<?php if($i 20) { break; } ?>
<li><a href="<?php echo osc_search_url(array('sCity' => osc_list_city_name()));?>"><?php echo osc_list_city_name();?></a> <em>(<?php echo osc_list_city_items();?>)</em></li>
<?php $i++; ?>
  <?php ?>
<?php ?>
« Last Edit: March 07, 2023, 06:31:41 PM by morfik »

*

morfik

  • ****
  • 169 posts
Re: Cities in Popular locations in the theme footer
« Reply #3 on: March 09, 2023, 10:48:39 PM »
Now when we have more cities in the database, often there are cities with the same name but in different region or even within the same region. It looks like that the script doesn't work well in such cases and it returns the first one. Is there a way to make it work better?

*

MB Themes

Re: Cities in Popular locations in the theme footer
« Reply #4 on: March 10, 2023, 04:32:03 PM »
well if there are 2 same cities in same region, you must probably rename them or add some comment.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots