Advertisement:

Author Topic: Just city in post and edit item form (SOLVED)  (Read 1431 times)

Batica

  • Newbie
  • *
  • Posts: 20
Just city in post and edit item form (SOLVED)
« on: September 07, 2016, 01:12:40 am »
Is it possible that users selects just city in post and edit item form?

I create a site for a small country so it is not necessary for users to choose between one country and one region.

Thanks in advance


« Last Edit: September 08, 2016, 01:53:29 pm by Batica »

ezybusy

  • Full Member
  • ***
  • Posts: 193
Re: Just city in post and edit item form
« Reply #1 on: September 07, 2016, 04:30:30 pm »
in item-post.php and item-edit.php find the lines that relate to country and region
especially look for :
for the country
Code: [Select]
<?php ItemForm::country_select(osc_get_countries(), osc_user()); ?>for the region
Code: [Select]
<?php ItemForm::region_text(osc_user());?>.

replace them with both line with the followings:

For country
Code: [Select]
<input type="hidden" name="country" id="country" value="your country"/>For region   
Code: [Select]
<input type="hidden" name="region" id="region" value="your region"/>

Batica

  • Newbie
  • *
  • Posts: 20
Re: Just city in post and edit item form
« Reply #2 on: September 07, 2016, 06:56:26 pm »
On item-post.php (newest bender theme) I didnt find:
Code: [Select]
<?php ItemForm::region_text(osc_user());?>so I replaced:
Code: [Select]
                                  <?php
                                    
if (bender_default_location_show_as() == 'dropdown') {
                                        
ItemForm::region_select($aRegionsosc_user());
                                    } else {
                                        
ItemForm::region_text(osc_user());
                                    }
                                    
?>
with code you gave me.

Region tab disappear but now I can not select city (without choosing region on first place)

ps. item-edit.php  just routes to item-post.php

ezybusy

  • Full Member
  • ***
  • Posts: 193
Re: Just city in post and edit item form
« Reply #3 on: September 08, 2016, 03:00:59 am »
In item-post.php look for this code:

Code: [Select]
<div class="box location">
                            <h2><?php _e('Listing Location''bender'); ?></h2>
                            <?php if(count(osc_get_countries()) > 1) { ?>
                            <div class="control-group">
                                <label class="control-label" for="country"><?php _e('Country''bender'); ?></label>
                                <div class="controls">
                                    <?php ItemForm::country_select(osc_get_countries(), osc_user()); ?>
                                </div>
                            </div>
                            <div class="control-group">
                                <label class="control-label" for="regionId"><?php _e('Region''bender'); ?></label>
                                <div class="controls">
                                    <?php
                                    
if (bender_default_location_show_as() == 'dropdown') {
                                        
ItemForm::region_select(osc_get_regions(osc_user_field('fk_c_country_code')), osc_user());
                                    } else {
                                        
ItemForm::region_text(osc_user());
                                    }
                                    
?>

                                </div>
                            </div>
                            <?php
                            
} else {
                                
$aCountries osc_get_countries();
                                
$aRegions osc_get_regions($aCountries[0]['pk_c_code']);
                                
?>

                            <input type="hidden" id="countryId" name="countryId" value="<?php echo osc_esc_html($aCountries[0]['pk_c_code']); ?>"/>
                            <div class="control-group">
                                <label class="control-label" for="region"><?php _e('Region''bender'); ?></label>
                                <div class="controls">
                                  <?php
                                    
if (bender_default_location_show_as() == 'dropdown') {
                                        
ItemForm::region_select($aRegionsosc_user());
                                    } else {
                                        
ItemForm::region_text(osc_user());
                                    }
                                    
?>

                                </div>
                            </div>
                            <?php ?>

                            <div class="control-group">
                                <label class="control-label" for="city"><?php _e('City''bender'); ?></label>
                                <div class="controls">
                                    <?php
                                    
if (bender_default_location_show_as() == 'dropdown') {
                                        if(
Params::getParam('action') != 'item_edit') {
                                            
ItemForm::city_select(nullosc_item());
                                        } else { 
// add new item
                                            
ItemForm::city_select(osc_get_cities(osc_user_region_id()), osc_user());
                                        }
                                    } else {
                                        
ItemForm::city_text(osc_user());
                                    }
                                    
?>

                                </div>
                            </div>
                            <div class="control-group">
                                <label class="control-label" for="cityArea"><?php _e('City Area''bender'); ?></label>
                                <div class="controls">
                                    <?php ItemForm::city_area_text(osc_user()); ?>
                                </div>
                            </div>
                            <div class="control-group">
                                <label class="control-label" for="address"><?php _e('Address''bender'); ?></label>
                                <div class="controls">
                                  <?php ItemForm::address_text(osc_user()); ?>
                                </div>
                            </div>
                        </div>

Then replace the block:

Code: [Select]
<h2><?php _e('Listing Location''bender'); ?></h2>
                            <?php if(count(osc_get_countries()) > 1) { ?>
                            <div class="control-group">
                                <label class="control-label" for="country"><?php _e('Country''bender'); ?></label>
                                <div class="controls">
                                    <?php ItemForm::country_select(osc_get_countries(), osc_user()); ?>
                                </div>
                            </div>
                            <div class="control-group">
                                <label class="control-label" for="regionId"><?php _e('Region''bender'); ?></label>
                                <div class="controls">
                                    <?php
                                    
if (bender_default_location_show_as() == 'dropdown') {
                                        
ItemForm::region_select(osc_get_regions(osc_user_field('fk_c_country_code')), osc_user());
                                    } else {
                                        
ItemForm::region_text(osc_user());
                                    }
                                    
?>

                                </div>
                            </div>
                            <?php
                            
} else {
                                
$aCountries osc_get_countries();
                                
$aRegions osc_get_regions($aCountries[0]['pk_c_code']);
                                
?>

                            <input type="hidden" id="countryId" name="countryId" value="<?php echo osc_esc_html($aCountries[0]['pk_c_code']); ?>"/>
                            <div class="control-group">
                                <label class="control-label" for="region"><?php _e('Region''bender'); ?></label>
                                <div class="controls">
                                  <?php
                                    
if (bender_default_location_show_as() == 'dropdown') {
                                        
ItemForm::region_select($aRegionsosc_user());
                                    } else {
                                        
ItemForm::region_text(osc_user());
                                    }
                                    
?>

                                </div>
                            </div>
                            <?php ?>

with the following:

Code: [Select]
<input type="hidden" name="country" id="country" value="your country"/>
<input type="hidden" name="region" id="region" value="your region"/>

and again look for:

Code: [Select]
<?php
                                    
if (bender_default_location_show_as() == 'dropdown') {
                                        if(
Params::getParam('action') != 'item_edit') {
                                            
ItemForm::city_select(nullosc_item());
                                        } else { 
// add new item
                                            
ItemForm::city_select(osc_get_cities(osc_user_region_id()), osc_user());
                                        }
                                    } else {
                                        
ItemForm::city_text(osc_user());
                                    }
                                    
?>

and repalce it with:

Code: [Select]
<?php ItemForm::city_selectosc_get_cities(), osc_user() ); ?>
so at the end the block code for location should look like the following:

Code: [Select]
<div class="box location">
                            <input type="hidden" name="country" id="country" value="your country"/>
<input type="hidden" name="region" id="region" value="your region"/>

                            <div class="control-group">
                                <label class="control-label" for="city"><?php _e('City''bender'); ?></label>
                                <div class="controls">
                                    <?php ItemForm::city_selectosc_get_cities(), osc_user() ); ?>
                                </div>
                            </div>
                            <div class="control-group">
                                <label class="control-label" for="cityArea"><?php _e('City Area''bender'); ?></label>
                                <div class="controls">
                                    <?php ItemForm::city_area_text(osc_user()); ?>
                                </div>
                            </div>
                            <div class="control-group">
                                <label class="control-label" for="address"><?php _e('Address''bender'); ?></label>
                                <div class="controls">
                                  <?php ItemForm::address_text(osc_user()); ?>
                                </div>
                            </div>
                        </div>

If you do everything correctly it should work.

Batica

  • Newbie
  • *
  • Posts: 20
Re: Just city in post and edit item form
« Reply #4 on: September 08, 2016, 12:26:34 pm »
It's working! It's working!

Thank youuuuuu!!!   :D  :D  :D

ezybusy

  • Full Member
  • ***
  • Posts: 193
Re: Just city in post and edit item form
« Reply #5 on: September 08, 2016, 12:56:51 pm »
You welcome.
You should add SOLVED in the title of this threat.