Advertisement:

Author Topic: (solved) The Tutorial Changing drop-down for locations doesn't work.  (Read 3177 times)

falouche

  • Newbie
  • *
  • Posts: 38
Hello,

I found in a post, this tutorial http://doc.osclass.org/Changing_between_drop-down_and_autocomplete_for_locations , but it does't work, it shows me an error in item-post.php,

from :

Code: [Select]
<?php ItemForm::region_text(osc_user()) ; ?>...
Code: [Select]
<?php ItemForm::city_text(osc_user()) ; ?>to:

Code: [Select]
<?php ItemForm::region_select(osc_get_regions(osc_user_country_code()), osc_user()) ; ?>...
Code: [Select]
<?php ItemForm::city_select(osc_get_cities(osc_user_region_id()), osc_user()) ; ?>
I use os-class 3.5.3
Theme modern 5.0.0

Thanks
« Last Edit: March 12, 2015, 09:04:33 pm by falouche »

frosticek

  • Hero Member
  • *****
  • Posts: 3948
Re: The Tutorial Changing drop-down for locations doesn't work.
« Reply #1 on: February 10, 2015, 11:05:15 am »
@falouche
What about this?

Quote
First, change the JS call from (this change is common to all three files):

<?php ItemForm::location_javascript_new(); ?>
to

<?php ItemForm::location_javascript(); ?>

falouche

  • Newbie
  • *
  • Posts: 38
Re: The Tutorial Changing drop-down for locations doesn't work.
« Reply #2 on: February 10, 2015, 11:11:15 pm »
Hey,

I have tried this code, I followed the tutorial step bey step and in final it shows me two tables of erreur at the line of this code 

Code: [Select]
<?php ItemForm::region_select(osc_get_regions(osc_user_country_code()), osc_user()) ; ?>
Code: [Select]
<?php ItemForm::city_select(osc_get_cities(osc_user_region_id()), osc_user()) ; ?>

frosticek

  • Hero Member
  • *****
  • Posts: 3948
Re: The Tutorial Changing drop-down for locations doesn't work.
« Reply #3 on: February 11, 2015, 12:58:53 am »
@falouche
I ask you again, did you do this?

Quote
First, change the JS call from (this change is common to all three files):

<?php ItemForm::location_javascript_new(); ?>
to

<?php ItemForm::location_javascript(); ?>

falouche

  • Newbie
  • *
  • Posts: 38
Re: The Tutorial Changing drop-down for locations doesn't work.
« Reply #4 on: February 11, 2015, 04:41:23 pm »
Yes, I did this in the three file. :-\

frosticek

  • Hero Member
  • *****
  • Posts: 3948
Re: The Tutorial Changing drop-down for locations doesn't work.
« Reply #5 on: February 11, 2015, 05:53:10 pm »
@falouche
What three file?
What is your URL?

falouche

  • Newbie
  • *
  • Posts: 38
Re: The Tutorial Changing drop-down for locations doesn't work.
« Reply #6 on: February 13, 2015, 09:53:12 pm »

I am with Wampserver in localhost, the website doesn't exist yet, the three files are item-edit.php and item-post.php, also an admin file (oc-admin/themes/modern/items/frm.php).

haralake

  • Newbie
  • *
  • Posts: 4
Re: The Tutorial Changing drop-down for locations doesn't work.
« Reply #7 on: March 11, 2015, 05:19:25 pm »
    I follow the tutorial step by step but is not working. Some code lines doesn't even exist.... e.g

    -Tutorial says that we must change those lines from frm.php [/li]


<?php ItemForm::country_text($item) ; ?>
<?php ItemForm::region_text($item) ; ?>
<?php ItemForm::city_text($item) ; ?>

But those lines on frm.php doesn't exist to change them.




-On item-edit.php tutorial says that we must change those lines:

<?php ItemForm::region_text(osc_user()) ; ?>
<?php ItemForm::city_text(osc_user()) ; ?>

But item-edit.php has only those 2 line of code!!

osc_add_hook('header','bender_nofollow_construct');
osc_current_web_theme_path('item-post.php');


-Tutorial says that we must change also those lines from item-post.php:

<?php ItemForm::location_javascript_new(); ?>

and
<?php ItemForm::region_text(osc_user()) ; ?>
<?php ItemForm::city_text(osc_user()) ; ?>

But when i change them with those you give on the tutorial i get error on the "post ad" page. Drop down fields doesn't work at all.


I sent you also one image attachment. And also the original files (without the changes) to see for your self. If there is still something that i didn't make perhaps you can change those files and share them to be able to download them all those have this problem, and believe me there are a lot out there that can't find working solution.

I thing that the tutorial is for older versions of Osclass. Some files changed and now you must update this tutorial. I have the latest Osclass version 3.5.3.

Please if it easy for someone who know the problem and also the solution to make the changes to the files and share them to the public. Thanks.



« Last Edit: March 11, 2015, 05:22:00 pm by haralake »

k33n

  • Newbie
  • *
  • Posts: 36
Re: The Tutorial Changing drop-down for locations doesn't work.
« Reply #8 on: March 12, 2015, 06:56:39 pm »
I got it to work.In bender theme you only need to edit item-post.php
1.Line 36 change
Code: [Select]
<?php ItemForm::location_javascript_new(); ?> to
Code: [Select]
<?php ItemForm::location_javascript(); ?>2.Line 94 Change
Code: [Select]
<?php ItemForm::region_text(osc_user()) ; ?>to
Code: [Select]
<?php ItemForm::region_select(osc_get_regions(), osc_user()) ; ?>3.Line 99 change
Code: [Select]
<?php ItemForm::city_text(osc_user()) ; ?> to
Code: [Select]
<?php ItemForm::city_select(osc_get_cities(osc_user_region_id()), osc_user()) ; ?>
This is how i've done it for my project (minimalist) and works fine in bender.Tested!However...i use one country,i dont know if it works fine with 2 or more countries.Modified file in attachment.
« Last Edit: March 12, 2015, 07:03:24 pm by k33n »

falouche

  • Newbie
  • *
  • Posts: 38
Re: The Tutorial Changing drop-down for locations doesn't work.
« Reply #9 on: March 12, 2015, 09:02:07 pm »
Hi

It's work fine thanks budy ...

another question can I get the same region select and city select on search-sidebar.php ?
 for what I can change this code to get the select bare ?
Code: [Select]
<h3><?php _e('City''bender'); ?></h3>
            <div class="row">
                <input class="input-text" type="text" id="sCity" name="sCity" value="<?php echo osc_esc_html(osc_search_city()); ?>" />
            </div>
Code: [Select]
<h3><?php _e('Region''bender'); ?></h3>
            <div class="row">
                <input class="input-text" type="text" id="sRegion" name="sRegion" value="<?php echo osc_esc_html(osc_search_region()); ?>" />
            </div>

@k33n
« Last Edit: March 12, 2015, 09:10:00 pm by falouche »

k33n

  • Newbie
  • *
  • Posts: 36
Re: (solved) The Tutorial Changing drop-down for locations doesn't work.
« Reply #10 on: March 13, 2015, 10:21:43 am »
Yes,it can be done.

First add this code right after the first php closing tag,arround line 27:
Code: [Select]
<script>
$(document).ready(function() {
   
         $("#sRegion").live("change",function(){
            var pk_c_code = $(this).val();
            <?php if($path=="admin") { ?>
                var url = '<?php echo osc_admin_base_url(true)."?page=ajax&action=cities&regionId="?>'   pk_c_code;
            <?php } else { ?>
                var url = '<?php echo osc_base_url(true)."?page=ajax&action=cities&regionId="?>'   pk_c_code;
            <?php }; ?>

            var result = '';

            if(pk_c_code != '') {
               
                $("#sCity").attr('disabled',false);
                $.ajax({
                    type: "GET",
                    url: url,
                    dataType: 'json',
                    success: function(data){
                        var length = data.length;
                        if(length > 0) {
                            result  = '<option selected value=""><?php _e("Select a city..."); ?></option>';
                            for(key in data) {
                                result  = '<option value="'   data[key].pk_i_id   '">'   data[key].s_name   '</option>';
                            }

                            $("#city").before('<select name="sCity" id="sCity" ></select>');
                            $("#city").remove();
                        } else {
                            result  = '<option value=""><?php _e('No results'?></option>';
                            $("#sCity").before('<input type="text" name="city" id="city" />');
                            $("#sCity").remove();
                        }
                        $("#sCity").html(result);
                    }
                 });
             } else {
                $("#sCity").attr('disabled',true);
             }
        });

        if( $("#sRegion").attr('value') == "")  {
            $("#sCity").attr('disabled',true);
        }

       
});
 </script>


Second find this code
Code: [Select]
<fieldset>
            <h3><?php _e('City''bender'); ?></h3>
            <div class="row">
                <input class="input-text" type="text" id="sCity" name="sCity" value="<?php echo osc_esc_html(osc_search_city()); ?>" />
            </div>
        </fieldset>

and replace it with
Code: [Select]
        <fieldset>
            <h3><?php _e('Region''bender'); ?></h3>
        <?php  $conn getConnection(); $aStates $conn->osc_dbFetchResults("SELECT * FROM %st_city "DB_TABLE_PREFIX); ?>
      <?php if (count($aStates) >= ) {?>
      <?php  foreach($aStates as $state) { ?>
  <?php $paese $state['fk_c_country_code']; ?> 
     <?php ?><?php ?>                 
        <?php $aRegions Region::newInstance()->getByCountry($paese); ?>
<?php  if(count($aRegions) >= ) { ?>
    <select id="sRegion" name="sRegion" class="">
      <option value="">Select Region</option>
      <?php  foreach($aRegions as $region) { ?>
      <option id="idregioni"  value="<?php echo $region['pk_i_id']; ?>"<?php if(Params::getParam('sRegion') == $region['pk_i_id']) { ?>selected<?php ?>><?php echo $region['s_name'] ; ?></option>
  <?php ?>
   </select><?php ?>
     
   <?php $regionId $_GET[sRegion]; ?>
     <?php  $conn getConnection(); $aCities $conn->osc_dbFetchResults("SELECT * FROM %st_city WHERE fk_i_region_id = '$regionId'"DB_TABLE_PREFIX); ?>
     <?php if (count($aCities) >= ) {?>
     <h3><?php _e('City''bender'); ?></h3>
   <select  name="sCity" id="sCity" class="">
      <option value="">Select City</option>
     
   <?php  foreach($aCities as $city) { ?>     
        <option value="<?php echo $city['pk_i_id']; ?>"<?php if(Params::getParam('sCity') == $city['pk_i_id']) { ?>selected<?php ?>><?php echo $city['s_name'] ; ?></option>
 <?php ?>
   </select>
<?php }?>       
</fieldset>

NOTE*This is not my work.I only share my experience following tutorials.This tutorial was made by Calinbehtuk.
« Last Edit: March 14, 2015, 03:40:50 pm by k33n »

falouche

  • Newbie
  • *
  • Posts: 38
Re: (solved) The Tutorial Changing drop-down for locations doesn't work.
« Reply #11 on: March 14, 2015, 12:35:00 am »
Hi Thank you for respond,

But the code work at his half, only the régions can be selected, the city still don't work, the bouton of select show but it display any cities, I try many times that don't want to work, I think there is somthing missing in the code,

Thank you to help me again.

@k33n

k33n

  • Newbie
  • *
  • Posts: 36
Re: (solved) The Tutorial Changing drop-down for locations doesn't work.
« Reply #12 on: March 14, 2015, 03:31:46 pm »
Looks like the forum script doesn't like "plus" signs.The code i posted was stripped. Modified file in attachement.
« Last Edit: March 14, 2015, 03:40:11 pm by k33n »

falouche

  • Newbie
  • *
  • Posts: 38
Re: (solved) The Tutorial Changing drop-down for locations doesn't work.
« Reply #13 on: March 14, 2015, 06:50:23 pm »
Thanks it works