• Уважаемый Гость! Если вы зарегистрировались на нашем форуме, значит вам нужна помощь! Мы всегда рады вам помочь, еще ни один пользователь не получил отказа! Но мы так же нуждаемся в Вашей поддержке. Проект полностью бесплатный, мы не имеем права требовать от вас денег, нам это и не нужно! Но от любой финансовой поддержки не откажемся. Проект развивается, но иногда очень тяжело его поддерживать, особенно в финансовом отношении. Если у вас есть возможность поддержать нас финансово, мы будем вам очень благодарны! С уважением, команда Оскласс Россия!
  • Изменение в правилах форума! В связи с огромным количеством вопросов поступающих в адрес технической поддержки мы решили изменить правила форума! Просим всех пользователей обратить внимание на данные изменения и четко их соблюдать!
  • Ребята, нуждаемся в программистах! Если хотите зарабатывать и есть время, пишите администраторам сайта. Есть база и инструменты, нужен опыт и знания =)
  • Уважаемые пользователи! На форуме появились разделы по работе с системой Yclas. Yclas - это скрипт доски объявлений. Нужны разработчики.

Как сделать выпадающий список регионов и городов?

denis

Активный пользователь
Можно ли как то сделать выпадающий список регионов и городов при публикации объявлений?
Тот вариант, когда начинаешь вводить начало названия города или города-вообще не вариант:)
т.к. многие по разному свои регионы называют..некоторые вообще сокращенно..
в связи с этим они(объявления) не присваиваются к регионам и городам..
хотелось бы сделать так, чтобы не сами вводили, а выбирали из того что есть, а если в списке не оказалось, то можно было выбрать другое и ввести еже свой регион или город..
Заранее благодарен за помощь..
 

Mr.Mrak

Известный пользователь
В item-post.php примерно строка 65
Код:
                                    <label for="countryId"><?php _e('Country', 'bcute'); ?></label>
под ней заменяешь на это
Код:
                                    <?php ItemForm::country_text($item) ; ?>
 

denis

Активный пользователь
Это вы мне наоборот предлагаете сделать!
мне нужно чтобы раскрывающийся список с регионами и городами был, а не самому текст вводить..
 

denis

Активный пользователь
а скажите, тогда, пожалуйста, какой именно текст нужно заменить?
 

denis

Активный пользователь
Ну вы же написали, что после строчки
<label for="countryId"><?php _e('Country', 'bcute'); ?></label>
нужно заменить на

<?php ItemForm::country_text($item) ; ?>
а что конкретно то заменить?
непонятно...:(
после строчки- это до куда? до какой строчки?
 

Mr.Mrak

Известный пользователь
А какая тема у вас установлена? На что заменять без разницы главное на это.
 

denis

Активный пользователь
да стандартная тема русская:)
но чтото я не понимаю вас:) как не важно что на что заменять?
 

Mr.Mrak

Известный пользователь
По моему вот эту строку:
Код:
                            <?php ItemForm::region_text(osc_user()); ?>
Заменяем:
Код:
                                    <?php ItemForm::country_text($item) ; ?>
 

Mr.Mrak

Известный пользователь
Я знаю точно в своей теме, если вы скинете файл item-post.php скажу и в вашей где.
 

denis

Активный пользователь
вот он:
Код:
<?php
    /*
    *      OSCLass – software for creating and publishing online classified
    *                          advertising platforms
    *
    *                        Copyright (C) 2010 OSCLASS
    *
    *      This program is free software: you can redistribute it and/or
    *    modify it under the terms of the GNU Affero General Public License
    *    as published by the Free Software Foundation, either version 3 of
    *            the License, or (at your option) any later version.
    *
    *    This program is distributed in the hope that it will be useful, but
    *        WITHOUT ANY WARRANTY; without even the implied warranty of
    *        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    *            GNU Affero General Public License for more details.
    *
    *      You should have received a copy of the GNU Affero General Public
    * License along with this program.  If not, see <http://www.gnu.org/licenses/>.
    */
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="<?php echo str_replace('_', '-', osc_current_user_locale()); ?>">
    <head>
        <?php osc_current_web_theme_path('head.php') ; ?>
        <meta name="robots" content="noindex, nofollow" />
        <meta name="googlebot" content="noindex, nofollow" />
       
        <!-- only item-post.php -->
        <script type="text/javascript" src="<?php echo osc_current_web_theme_js_url('jquery.validate.min.js') ; ?>"></script>
        <?php ItemForm::location_javascript_new(); ?>
        <?php if(osc_images_enabled_at_items()) ItemForm::photos_javascript(); ?>
        <script type="text/javascript">
            function uniform_input_file(){
                photos_div = $('div.photos');
                $('div',photos_div).each(
                    function(){
                        if( $(this).find('div.uploader').length == 0  ){
                            divid = $(this).attr('id');
                            if(divid != 'photos'){
                                divclass = $(this).hasClass('box');
                                if( !$(this).hasClass('box') & !$(this).hasClass('uploader') & !$(this).hasClass('row')){
                                    $("div#"+$(this).attr('id')+" input:file").uniform({fileDefaultText: fileDefaultText,fileBtnText: fileBtnText});
                                }
                            }
                        }
                    }
                );
            }
           
            setInterval("uniform_plugins()", 250);
            function uniform_plugins() {
               
                var content_plugin_hook = $('#plugin-hook').text();
                content_plugin_hook = content_plugin_hook.replace(/(\r\n|\n|\r)/gm,"");
                if( content_plugin_hook != '' ){
                   
                    var div_plugin_hook = $('#plugin-hook');
                    var num_uniform = $("div[id*='uniform-']", div_plugin_hook ).size();
                    if( num_uniform == 0 ){
                        if( $('#plugin-hook input:text').size() > 0 ){
                            $('#plugin-hook input:text').uniform();
                        }
                        if( $('#plugin-hook select').size() > 0 ){
                            $('#plugin-hook select').uniform();
                        }
                    }
                }
            }
            <?php if(osc_locale_thousands_sep()!='' || osc_locale_dec_point() != '') { ?>
            $().ready(function(){
                $("#price").blur(function(event) {
                    var price = $("#price").attr("value");
                    <?php if(osc_locale_thousands_sep()!='') { ?>
                    while(price.indexOf('<?php echo osc_esc_js(osc_locale_thousands_sep());  ?>')!=-1) {
                        price = price.replace('<?php echo osc_esc_js(osc_locale_thousands_sep());  ?>', '');
                    }
                    <?php }; ?>
                    <?php if(osc_locale_dec_point()!='') { ?>
                    var tmp = price.split('<?php echo osc_esc_js(osc_locale_dec_point())?>');
                    if(tmp.length>2) {
                        price = tmp[0]+'<?php echo osc_esc_js(osc_locale_dec_point())?>'+tmp[1];
                    }
                    <?php }; ?>
                    $("#price").attr("value", price);
                });
            });
            <?php }; ?>
        </script>
        <!-- end only item-post.php -->
    </head>
    <body>
        <?php osc_current_web_theme_path('header.php') ; ?>
        <div class="content add_item">
            <h1><strong><?php _e('Publish a listing', 'russia'); ?></strong></h1>
            <ul id="error_list"></ul>
            <form name="item" action="<?php echo osc_base_url(true);?>" method="post" enctype="multipart/form-data">
                <fieldset>
                <input type="hidden" name="action" value="item_add_post" />
                <input type="hidden" name="page" value="item" />
                    <div class="box general_info">
                        <h2><?php _e('General Information', 'russia'); ?></h2>
                        <div class="row">
                            <label for="catId"><?php _e('Category', 'russia'); ?> *</label>
                            <?php ItemForm::category_select(null, null, __('Select a category', 'russia')); ?>
                        </div>
                        <div class="row">
                            <?php ItemForm::multilanguage_title_description(); ?>
                        </div>
                    </div>
                    <?php if( osc_price_enabled_at_items() ) { ?>
                    <div class="box price">
                        <label for="price"><?php _e('Price', 'russia'); ?></label>
                        <?php ItemForm::price_input_text(); ?>
                        <?php ItemForm::currency_select(); ?>
                    </div>
                    <?php } ?>
                    <?php if( osc_images_enabled_at_items() ) { ?>
                    <div class="box photos">
                        <h2><?php _e('Photos', 'russia'); ?></h2>
                        <div id="photos">
                            <div class="row">
                                <input type="file" name="photos[]" />
                            </div>
                        </div>
                        <a href="#" onclick="addNewPhoto(); uniform_input_file(); return false;"><?php _e('Add new photo', 'russia'); ?></a>
                    </div>
                    <?php } ?>
               
                    <div class="box location">
                        <h2><?php _e('Listing Location', 'russia'); ?></h2>
                        <div class="row">
                            <label for="countryId"><?php _e('Country', 'russia'); ?></label>
                            <?php ItemForm::country_select(osc_get_countries(), osc_user()) ; ?>
                        </div>
                        <div class="row">
                            <label for="regionId"><?php _e('Region', 'russia'); ?></label>
                            <?php ItemForm::region_text(osc_user()) ; ?>
                        </div>
                        <div class="row">
                            <label for="city"><?php _e('City', 'russia'); ?></label>
                            <?php ItemForm::city_text(osc_user()) ; ?>
                        </div>
                        <div class="row">
                            <label for="city"><?php _e('City Area', 'russia'); ?></label>
                            <?php ItemForm::city_area_text(osc_user()) ; ?>
                        </div>
                        <div class="row">
                            <label for="address"><?php _e('Address', 'russia'); ?></label>
                            <?php ItemForm::address_text(osc_user()) ; ?>
                        </div>
                    </div>
                    <!-- seller info -->
                    <?php if(!osc_is_web_user_logged_in() ) { ?>
                    <div class="box seller_info">
                        <h2><?php _e("Seller's information", 'russia'); ?></h2>
                        <div class="row">
                            <label for="contactName"><?php _e('Name', 'russia'); ?></label>
                            <?php ItemForm::contact_name_text() ; ?>
                        </div>
                        <div class="row">
                            <label for="contactEmail"><?php _e('E-mail', 'russia'); ?> *</label>
                            <?php ItemForm::contact_email_text() ; ?>
                        </div>
                        <div class="row">
                            <div style="width: 120px;text-align: right;float:left;">
                                <?php ItemForm::show_email_checkbox() ; ?>
                            </div>
                            <label for="showEmail" style="width: 250px;"><?php _e('Show e-mail on the listing page', 'russia'); ?></label>
                        </div>
                    </div>
                    <?php }?>
                    <?php ItemForm::plugin_post_item(); ?>
                    <?php if( osc_recaptcha_items_enabled() ) {?>
                    <div class="box">
                        <div class="row">
                            <?php osc_show_recaptcha(); ?>
                        </div>
                    </div>
                    <?php }?> 
                <div class="clear"></div>
                <button  type="submit"><?php _e('Publish', 'russia'); ?></button>
                </fieldset>
            </form>
        </div>
        <?php osc_current_web_theme_path('footer.php') ; ?>
    </body>
</html>
 

Mr.Mrak

Известный пользователь
Я прикрепил файл, замените на свой.
 

Вложения

  • item-post.zip
    2,6 КБ · Просмотры: 44
  • Like
Реакции: oddd

denis

Активный пользователь
это вообщче не то...теперь везеде отображается россия, россия вместо полей для ввода региона и города...
 

denis

Активный пользователь
По сути вот так нужно сделать:
Код:
<?php
    /*
    *      OSCLass – software for creating and publishing online classified
    *                          advertising platforms
    *
    *                        Copyright (C) 2010 OSCLASS
    *
    *      This program is free software: you can redistribute it and/or
    *    modify it under the terms of the GNU Affero General Public License
    *    as published by the Free Software Foundation, either version 3 of
    *            the License, or (at your option) any later version.
    *
    *    This program is distributed in the hope that it will be useful, but
    *        WITHOUT ANY WARRANTY; without even the implied warranty of
    *        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    *            GNU Affero General Public License for more details.
    *
    *      You should have received a copy of the GNU Affero General Public
    * License along with this program.  If not, see <http://www.gnu.org/licenses/>.
    */
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="<?php echo str_replace('_', '-', osc_current_user_locale()); ?>">
    <head>
        <?php osc_current_web_theme_path('head.php') ; ?>
        <meta name="robots" content="noindex, nofollow" />
        <meta name="googlebot" content="noindex, nofollow" />
       
        <!-- only item-post.php -->
        <script type="text/javascript" src="<?php echo osc_current_web_theme_js_url('jquery.validate.min.js') ; ?>"></script>
        <?php ItemForm::location_javascript_new(); ?>
        <?php if(osc_images_enabled_at_items()) ItemForm::photos_javascript(); ?>
        <script type="text/javascript">
            function uniform_input_file(){
                photos_div = $('div.photos');
                $('div',photos_div).each(
                    function(){
                        if( $(this).find('div.uploader').length == 0  ){
                            divid = $(this).attr('id');
                            if(divid != 'photos'){
                                divclass = $(this).hasClass('box');
                                if( !$(this).hasClass('box') & !$(this).hasClass('uploader') & !$(this).hasClass('row')){
                                    $("div#"+$(this).attr('id')+" input:file").uniform({fileDefaultText: fileDefaultText,fileBtnText: fileBtnText});
                                }
                            }
                        }
                    }
                );
            }
           
            setInterval("uniform_plugins()", 250);
            function uniform_plugins() {
               
                var content_plugin_hook = $('#plugin-hook').text();
                content_plugin_hook = content_plugin_hook.replace(/(\r\n|\n|\r)/gm,"");
                if( content_plugin_hook != '' ){
                   
                    var div_plugin_hook = $('#plugin-hook');
                    var num_uniform = $("div[id*='uniform-']", div_plugin_hook ).size();
                    if( num_uniform == 0 ){
                        if( $('#plugin-hook input:text').size() > 0 ){
                            $('#plugin-hook input:text').uniform();
                        }
                        if( $('#plugin-hook select').size() > 0 ){
                            $('#plugin-hook select').uniform();
                        }
                    }
                }
            }
            <?php if(osc_locale_thousands_sep()!='' || osc_locale_dec_point() != '') { ?>
            $().ready(function(){
                $("#price").blur(function(event) {
                    var price = $("#price").attr("value");
                    <?php if(osc_locale_thousands_sep()!='') { ?>
                    while(price.indexOf('<?php echo osc_esc_js(osc_locale_thousands_sep());  ?>')!=-1) {
                        price = price.replace('<?php echo osc_esc_js(osc_locale_thousands_sep());  ?>', '');
                    }
                    <?php }; ?>
                    <?php if(osc_locale_dec_point()!='') { ?>
                    var tmp = price.split('<?php echo osc_esc_js(osc_locale_dec_point())?>');
                    if(tmp.length>2) {
                        price = tmp[0]+'<?php echo osc_esc_js(osc_locale_dec_point())?>'+tmp[1];
                    }
                    <?php }; ?>
                    $("#price").attr("value", price);
                });
            });
            <?php }; ?>
        </script>
        <!-- end only item-post.php -->
    </head>
    <body>
        <?php osc_current_web_theme_path('header.php') ; ?>
        <div class="content add_item">
            <h1><strong><?php _e('Publish a listing', 'russia'); ?></strong></h1>
            <ul id="error_list"></ul>
            <form name="item" action="<?php echo osc_base_url(true);?>" method="post" enctype="multipart/form-data">
                <fieldset>
                <input type="hidden" name="action" value="item_add_post" />
                <input type="hidden" name="page" value="item" />
                    <div class="box general_info">
                        <h2><?php _e('General Information', 'russia'); ?></h2>
                        <div class="row">
                            <label for="catId"><?php _e('Category', 'russia'); ?> *</label>
                            <?php ItemForm::category_select(null, null, __('Select a category', 'russia')); ?>
                        </div>
                        <div class="row">
                            <?php ItemForm::multilanguage_title_description(); ?>
                        </div>
                    </div>
                    <?php if( osc_price_enabled_at_items() ) { ?>
                    <div class="box price">
                        <label for="price"><?php _e('Price', 'russia'); ?></label>
                        <?php ItemForm::price_input_text(); ?>
                        <?php ItemForm::currency_select(); ?>
                    </div>
                    <?php } ?>
                    <?php if( osc_images_enabled_at_items() ) { ?>
                    <div class="box photos">
                        <h2><?php _e('Photos', 'russia'); ?></h2>
                        <div id="photos">
                            <div class="row">
                                <input type="file" name="photos[]" />
                            </div>
                        </div>
                        <a href="#" onclick="addNewPhoto(); uniform_input_file(); return false;"><?php _e('Add new photo', 'russia'); ?></a>
                    </div>
                    <?php } ?>
               
                    <div class="box location">
                        <h2><?php _e('Listing Location', 'russia'); ?></h2>
                        <div class="row">
                            <label for="countryId"><?php _e('Country', 'russia'); ?></label>
                            <?php ItemForm::country_select(osc_get_countries(), osc_user()) ; ?>
                        </div>
                        <div class="row">
                            <label for="regionId"><?php _e('Region', 'russia'); ?></label>
                            <?php ItemForm::region_select(osc_get_regions(), osc_user()) ; ?>
                        </div>
                        <div class="row">
                            <label for="city"><?php _e('City', 'russia'); ?></label>
                            <?php ItemForm::city_select(osc_get_cities(), osc_user()) ; ?>
                        </div>
                        <div class="row">
                            <label for="city"><?php _e('City Area', 'russia'); ?></label>
                            <?php ItemForm::city_area_text(osc_user()) ; ?>
                        </div>
                        <div class="row">
                            <label for="address"><?php _e('Address', 'russia'); ?></label>
                            <?php ItemForm::address_text(osc_user()) ; ?>
                        </div>
                    </div>
                    <!-- seller info -->
                    <?php if(!osc_is_web_user_logged_in() ) { ?>
                    <div class="box seller_info">
                        <h2><?php _e("Seller's information", 'russia'); ?></h2>
                        <div class="row">
                            <label for="contactName"><?php _e('Name', 'russia'); ?></label>
                            <?php ItemForm::contact_name_text() ; ?>
                        </div>
                        <div class="row">
                            <label for="contactEmail"><?php _e('E-mail', 'russia'); ?> *</label>
                            <?php ItemForm::contact_email_text() ; ?>
                        </div>
                        <div class="row">
                            <div style="width: 120px;text-align: right;float:left;">
                                <?php ItemForm::show_email_checkbox() ; ?>
                            </div>
                            <label for="showEmail" style="width: 250px;"><?php _e('Show e-mail on the listing page', 'russia'); ?></label>
                        </div>
                    </div>
                    <?php }?>
                    <?php ItemForm::plugin_post_item(); ?>
                    <?php if( osc_recaptcha_items_enabled() ) {?>
                    <div class="box">
                        <div class="row">
                            <?php osc_show_recaptcha(); ?>
                        </div>
                    </div>
                    <?php }?> 
                <div class="clear"></div>
                <button  type="submit"><?php _e('Publish', 'russia'); ?></button>
                </fieldset>
            </form>
        </div>
        <?php osc_current_web_theme_path('footer.php') ; ?>
    </body>
</html>
 

denis

Активный пользователь
но почемуто в этом случае в списке городов отображаются только 4 города..странно..а регионы все отображаются..
тут както взаимосвязь с выбранным регионом нужно сделать, но я сам не програмер..и в пхп не соображаю..только методом тыка:)
и хотелось бы сделать еще в списке вариант "другой", при выборе которого будет появляться текстовое поле для ввода города/региона.
 
Верх