Advertisement:

Author Topic: SOLVED: List Cities in sidebar more than specific count  (Read 1222 times)

rizwan65

  • Newbie
  • *
  • Posts: 49
SOLVED: List Cities in sidebar more than specific count
« on: March 29, 2015, 06:28:24 pm »
Hi
I have found a tutorial here in which it is guided how to list cities or regions in side bar either all cities/regions or cities/regions with ads

I am trying to list cities in side bar with more than specific ad counts i.e cities with more than 100 ads

Below is the code
   
<?php View::newInstance()->_exportVariableToView('list_cities', Search::newInstance()->listCities('%%%%', '>') ) ; ?>


Any help will be appriciated
« Last Edit: April 06, 2015, 05:18:35 am by rizwan65 »

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: List Cities in sidebar more than specific count
« Reply #1 on: March 29, 2015, 06:40:16 pm »
Hi,

A variant of the code I put here:

Code: [Select]
    <?php $conn getConnection();
    
$popular_cities $conn->osc_dbFetchResults("SELECT c.s_name as city_name, cs.i_num_items as items
     FROM %st_city_stats cs
     INNER JOIN %st_city c ON c.pk_i_id = cs.fk_i_city_id
     WHERE cs.i_num_items > 100
     ORDER BY cs.i_num_items DESC"
DB_TABLE_PREFIXDB_TABLE_PREFIX);

    
View::newInstance()->_exportVariableToView('cities'$popular_cities);

    while(
osc_has_cities()) {
        echo 
osc_city_name() . ' (' osc_city_items() . ')<br />';
    } 
?>


Of course you may change the echo line to suit your needs.

Regards

rizwan65

  • Newbie
  • *
  • Posts: 49
Re: List Cities in sidebar more than specific count
« Reply #2 on: April 04, 2015, 07:00:59 am »
Thanks for your help

I worked fine but with one problem
The cities listed have the same link url for all cities

Below is the code

Code: [Select]

  <?php $conn getConnection();
    
$popular_cities $conn->osc_dbFetchResults("SELECT c.s_name as city_name, cs.i_num_items as items
     FROM %st_city_stats cs
     INNER JOIN %st_city c ON c.pk_i_id = cs.fk_i_city_id
     WHERE cs.i_num_items > 40
     ORDER BY cs.i_num_items DESC"
DB_TABLE_PREFIXDB_TABLE_PREFIX);

    
View::newInstance()->_exportVariableToView('cities'$popular_cities); ?>

<?php if(osc_count_list_cities() > ) { ?>
        <div class="box location">


  <h3><strong><?php _e("Popular Cities"'infinity') ; ?></strong></h3>
            <ul>
           
<?php while(osc_has_cities() ) { ?>
                <li><a href="<?php echo osc_list_city_url(); ?>"><?php echo osc_city_name() ; ?> <em>(<?php echo osc_city_items() ; ?>)</em></a></li>
            <?php ?>
            </ul>


teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: List Cities in sidebar more than specific count
« Reply #3 on: April 04, 2015, 01:07:49 pm »
Use osc_city_url() instead of osc_list_city_url().

Regards

rizwan65

  • Newbie
  • *
  • Posts: 49
Re: List Cities in sidebar more than specific count
« Reply #4 on: April 05, 2015, 06:15:28 am »
@teseo
Thanks it worked fine

rizwan65

  • Newbie
  • *
  • Posts: 49
Re: List Cities in sidebar more than specific count
« Reply #5 on: April 05, 2015, 08:08:00 am »
@teseo
Is this possible to list the cities in 2 or 3 columns

i.e
City1    City2    City3
City4    City5    City6

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: List Cities in sidebar more than specific count
« Reply #6 on: April 05, 2015, 01:38:18 pm »
Hi,

That's another matter altogether, so first please add [SOLVED] to the title of this thread.

My suggestion, study how it's done to render Ads on Gallery view (bender/loop.php):

Quote
        $i = 0;

        if($type == 'latestItems'){
            while ( osc_has_latest_items() ) {
                $class = '';
                if($i%3 == 0){
                    $class = 'first';
                }
                bender_draw_item($class);
                $i++;
            }
        }

Every X listed items (3 in this case) a linebreak of sorts is added.

Regards