*

mheston

  • ***
  • 48 posts
How do I change all locations to cities on home page
« on: December 14, 2021, 04:46:22 AM »
How do I change all locations to cities on home page

<div id="home-regs">
    <h2><?php _e('All locations', 'sigma'); ?></h2>

    <div class="wrap">
      <?php $regions = RegionStats::newInstance()->listRegions('%%%%', '>', 'i_num_items DESC'); ?>

      <?php $i = 1; ?>
      <?php foreach($regions as $r) { ?>
        <?php if($i <= 20) { ?>
          <div><a href="<?php echo osc_search_url(array('page' => 'search', 'sRegion' => $r['pk_i_id']));?>"><i class="fas fa-location-arrow"></i> <span><?php echo $r['s_name']; ?></span> <em>(<?php echo $r['i_num_items']; ?>)</em></a></div>
          <?php $i++; ?>
        <?php } ?>
      <?php } ?>

*

MB Themes

Re: How do I change all locations to cities on home page
« Reply #1 on: December 17, 2021, 02:17:32 PM »
@mheston
Try this:
Code: [Select]
  <div id="home-regs">
    <h2><?php _e('All locations''sigma'); ?></h2>

    <div class="wrap">
      <?php $cities CityStats::newInstance()->listCities('%%%%''>''i_num_items DESC'); ?>

      <?php $i 1?>
      <?php foreach($cities as $c) { ?>
        <?php if($i <= 20) { ?>
          <div><a href="<?php echo osc_search_url(array('page' => 'search''sCity' => $c['city_id']));?>"><i class="fas fa-location-arrow"></i> <span><?php echo $c['city_name']; ?></span> <em>(<?php echo $c['items']; ?>)</em></a></div>
          <?php $i++; ?>
        <?php ?>
      <?php ?>

    </div>
  </div>
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

mheston

  • ***
  • 48 posts
Re: How do I change all locations to cities on home page
« Reply #2 on: December 21, 2021, 09:51:44 PM »
Thank you very much for the help. I think it shows the region when the region has a listing, how would I show all regions even if there is no listing. for example,

 Texas (0)
 California (0)
 Ohio (0)
 
 would this be the code that would need changed
 
 <?php if($i <= 20) { ?>
 
 and thanks for the tip about the cache plugin, I purchased it and it works great.

*

MB Themes

Re: How do I change all locations to cities on home page
« Reply #3 on: December 22, 2021, 01:56:46 PM »
@mheston
You must develop it, I do not have code for that  :-*
Require usage of different functions.

Maybe if you change this:
Code: [Select]
      <?php $cities CityStats::newInstance()->listCities('%%%%''>''i_num_items DESC'); ?>

Into this:
Code: [Select]
      <?php $cities CityStats::newInstance()->listCities('%%%%''>=''i_num_items DESC'); ?>

it could work as well.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots