Change locations on main page sidebar from cities to regions/states

From Osclass
Jump to: navigation, search

Cities at sidebar

                <div id="sidebar">
                    <div class="navigation">
                        <?php if(osc_count_list_cities() > 0 ) { ?>
                        <div class="box location">
                            <h3><strong><?php _e("Location", 'modern') ; ?></strong></h3>
                            <ul>
                            <?php while(osc_has_list_cities() ) { ?>
                                <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 } ?>
                            </ul>
                        </div>
                        <?php } ?>
                    </div>
                </div>

Regions at sidebar

                <div id="sidebar">
                    <div class="navigation">
                        <?php if(osc_count_list_regions() > 0 ) { ?>
                        <div class="box location">
                            <h3><strong><?php _e("Location", 'modern') ; ?></strong></h3>
                            <ul>
                            <?php while(osc_has_list_regions() ) { ?>
                                <li><a href="<?php echo osc_search_url( array( 'sRegion' => osc_list_region_name() ) ) ; ?>"><?php echo osc_list_region_name() ; ?></a> <em>(<?php echo osc_list_region_items() ; ?>)</em></li>
                            <?php } ?>
                            </ul>
                        </div>
                        <?php } ?>
                    </div>
                </div>

Countries at sidebar

                <div id="sidebar">
                    <div class="navigation">
                        <?php if(osc_count_list_countries() > 0 ) { ?>
                        <div class="box location">
                            <h3><strong><?php _e("Location", 'modern') ; ?></strong></h3>
                            <ul>
                            <?php while(osc_has_list_countries() ) { ?>
                                <li><a href="<?php echo osc_search_url( array( 'sCountry' => osc_list_country_code() ) ) ; ?>"><?php echo osc_list_country_name() ; ?></a> <em>(<?php echo osc_list_country_items() ; ?>)</em></li>
                            <?php } ?>
                            </ul>
                        </div>
                        <?php } ?>
                    </div>
                </div>


This customization will allow you to change the Location sidebar on the main page to show regions/states instead of cities.


Here is a before and after example of this customization:


Locationsidebar beforeafter.jpg

What to edit:

Edit the file main.php located within the theme folder.


Find this code:

                        <div class="navigation">
                            <?php if(osc_count_list_cities()>0) {?>
                            <div class="box location">
                                <h3><strong><?php _e("Location", 'modern'); ?></strong></h3>
                                <ul>
                                <?php while(osc_has_list_cities()) { ?>
                                    <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 } ?>
                                </ul>
                            </div>
                            <?php } ?>
                         </div>


And replace it with this code:

                        <div class="navigation">
                            <?php if(osc_count_list_regions()>0) {?>
                            <div class="box location">
                                <h3><strong><?php _e("Location", 'modern'); ?></strong></h3>
                                <ul>
                                <?php while(osc_has_list_regions()) { ?>
                                    <li><a href="<?php echo osc_search_url(array('sRegion' => osc_list_region_name()));?>"><?php echo osc_list_region_name();?></a> <em>(<?php echo osc_list_region_items();?>)</em></li>
                                <?php } ?>
                                </ul>
                            </div>
                            <?php } ?>
                        </div>


All this is being changed is where it said city or cities, it's now changed to region or regions, respectively (and with respect to capitalization).

Also note that in this example code, the modern theme was used. Make sure to change this to your own theme if different from modern.



--Jesse 06:17, 5 January 2012 (CET)