Advertisement:

Author Topic: Add Phone Number and other field for Bender Theme  (Read 32811 times)

shamim_biplob

  • Full Member
  • ***
  • Posts: 169
Re: Add Phone Number and other field for Bender Theme
« Reply #15 on: October 14, 2013, 02:22:53 pm »
Quote
At ItemAction.php, function add() and edit(), above
Code: [Select]
            $_meta = Field::newInstance()->findByCategory($aItem['catId']);
            $meta = Params::getParam("meta");

add this

Code: [Select]
            $flash_error .=
                ((!osc_validate_text($aItem['s_contact_phone'], 7, false)) ? _m("Phone Number too short.") . PHP_EOL : '' ) .
                ((!osc_validate_max($aItem['s_contact_phone'], 20)) ? _m("Phone Number too long.") . PHP_EOL : '' );
           
            $_meta = Field::newInstance()->findByCategory($aItem['catId']);
            $meta = Params::getParam("meta");

I tried this before. but dont know why this is not working for me. if my client side validation failed, item publish. my server side validation work for location, title, description.. i tried following code but no result.
Code: [Select]
$flash_error .=
((!osc_validate_text($aItem['s_contact_phone'], 7, false)) ? _m("Phone Number too short.") . PHP_EOL : '' ) .
((!osc_validate_number($aItem['s_contact_phone'])) ? _m("Invalid phone number.") . PHP_EOL : '' ) .
                                ((!osc_validate_max($aItem['s_contact_phone'], 20)) ? _m("Phone Number too long.") . PHP_EOL : '' );

i tried the code after ((!osc_validate_email($contactEmail)) ? _m("Email invalid.") . PHP_EOL : '' ) . also(without $flash_error .=)  but no result.

byteGator

  • Osclass Hero
  • Sr. Member
  • *
  • Posts: 346
  • Simple Mind is a Beautiful Mind
Re: Add Phone Number and other field for Bender Theme
« Reply #16 on: October 15, 2013, 08:06:29 am »
Thanks a lot bytegator! works nice!
if you have time can you show how to make phone and mail hide like you have in http://iklangratis.org ?

you like this type of phone number hide?
http://www.banglardokan.com/electronics/laptopstablets/dell-vostro-1014-i4521

i can share code.

Hi Shamim...

Yes, it is nice. Please share it.

Thanks.

byteGator

  • Osclass Hero
  • Sr. Member
  • *
  • Posts: 346
  • Simple Mind is a Beautiful Mind
Re: Add Phone Number and other field for Bender Theme
« Reply #17 on: October 15, 2013, 09:07:17 am »
Quote
At ItemAction.php, function add() and edit(), above
Code: [Select]
            $_meta = Field::newInstance()->findByCategory($aItem['catId']);
            $meta = Params::getParam("meta");

add this

Code: [Select]
            $flash_error .=
                ((!osc_validate_text($aItem['s_contact_phone'], 7, false)) ? _m("Phone Number too short.") . PHP_EOL : '' ) .
                ((!osc_validate_max($aItem['s_contact_phone'], 20)) ? _m("Phone Number too long.") . PHP_EOL : '' );
           
            $_meta = Field::newInstance()->findByCategory($aItem['catId']);
            $meta = Params::getParam("meta");

I tried this before. but dont know why this is not working for me. if my client side validation failed, item publish. my server side validation work for location, title, description.. i tried following code but no result.
Code: [Select]
$flash_error .=
((!osc_validate_text($aItem['s_contact_phone'], 7, false)) ? _m("Phone Number too short.") . PHP_EOL : '' ) .
((!osc_validate_number($aItem['s_contact_phone'])) ? _m("Invalid phone number.") . PHP_EOL : '' ) .
                                ((!osc_validate_max($aItem['s_contact_phone'], 20)) ? _m("Phone Number too long.") . PHP_EOL : '' );

i tried the code after ((!osc_validate_email($contactEmail)) ? _m("Email invalid.") . PHP_EOL : '' ) . also(without $flash_error .=)  but no result.

Hi shamim_biplob

Sorry, I made a mistake.
Please change 's_contact_phone' to 'contactPhone'

Code: [Select]
            $flash_error .=
                ((!osc_validate_text($aItem['contactPhone'], 7, false)) ? _m("Phone Number too short.") . PHP_EOL : '' ) .
                ((!osc_validate_max($aItem['contactPhone'], 20)) ? _m("Phone Number too long.") . PHP_EOL : '' );

shamim_biplob

  • Full Member
  • ***
  • Posts: 169
Re: Add Phone Number and other field for Bender Theme
« Reply #18 on: October 15, 2013, 12:36:51 pm »
Quote
Hi shamim_biplob

Sorry, I made a mistake.
Please change 's_contact_phone' to 'contactPhone'

Code: [Select]
            $flash_error .=
                ((!osc_validate_text($aItem['contactPhone'], 7, false)) ? _m("Phone Number too short.") . PHP_EOL : '' ) .
                ((!osc_validate_max($aItem['contactPhone'], 20)) ? _m("Phone Number too long.") . PHP_EOL : '' );

thank you for your reply and it is working nice..


can u help me little more?

in item-post.php

we use <?php ItemForm::title_input('title',osc_locale_code(), osc_esc_html( bender_item_title() )); ?>

but if we see the source code of publish ad page we find <input id="title[en_US]" type="text" name="title[en_US]" value=""/>

how we get that?
in item.form.class.php i can not find anything. can you help me? i want to make more like placeholder, maxlength etc but dont know how?
what does it mean by generic_input_text?
                   

byteGator

  • Osclass Hero
  • Sr. Member
  • *
  • Posts: 346
  • Simple Mind is a Beautiful Mind
Re: Add Phone Number and other field for Bender Theme
« Reply #19 on: October 16, 2013, 06:00:15 am »
Quote
in item-post.php

we use <?php ItemForm::title_input('title',osc_locale_code(), osc_esc_html( bender_item_title() )); ?>

but if we see the source code of publish ad page we find <input id="title[en_US]" type="text" name="title[en_US]" value=""/>

how we get that?
in item.form.class.php i can not find anything. can you help me? i want to make more like placeholder, maxlength etc but dont know how?
what does it mean by generic_input_text?
                 

Osclass is design for multilanguage. Therefore an item can have more than one title and description. Each one have different languange. For example, an Item can have title[en_US] = 'Car', title[id_ID] = 'Mobil', title[spain] = 'Coche'.

If you want to add placeholder and maxlength, you can not use default generic_input_text. Or you must modify it.

For example:
Code: [Select]
        static protected function generic_textarea($name, $value, $maxLength = null, $rowlen = 10) {
            echo '<textarea id="' . preg_replace('|([^_a-zA-Z0-9-]+)|', '', $name) . '" name="' . $name . '" rows="' . $rowlen . '" ';
            if (isset($maxLength)) echo 'maxlength="' . $maxLength . '" ';
            echo '>' . $value . '</textarea>';
        }

Or modify just item.form.class / user.form.class:

Code: [Select]
        static public function info_textarea($name, $locale = 'en_US', $value = '') {
            echo '<textarea id="' . $name . $locale. '" name="' . $name . '[' . $locale . ']" rows="10" maxlength="512" placeholder="Put your information here....">' . $value . '</textarea>';
        }


 

shamim_biplob

  • Full Member
  • ***
  • Posts: 169
Re: Add Phone Number and other field for Bender Theme
« Reply #20 on: October 16, 2013, 07:40:02 am »
thank you so much. i didn't know in form.form.class there is everything. i searched, but didn't get it before.

this is multilanguage script thats why after title there is like [en_US]. but for that my following script is not working for title or description field, it is working for price field. if i remove [en_US] than it works but in database nothing save. any way to make it works for description field?

Code: [Select]
<script>

$(document).ready(function () {

  $('#price').keypress(function (event) {
    var max = 250;
    var len = $(this).val().length;

    if (event.which < 0x20) {
      // e.which < 0x20, then it's not a printable character
      // e.which === 0 - Not a character
      return; // Do nothing
    }

    if (len >= max) {
      event.preventDefault();
    }

  });

  $('#price').keyup(function (event) {
    var max = 250;
    var len = $(this).val().length;
    var char = max - len;

    $('#textleft').text(char + ' characters left');

  });

});

</script>
Code: [Select]
<div id="textleft">250 characters left</div>

res909

  • Newbie
  • *
  • Posts: 12
Re: Add Phone Number and other field for Bender Theme
« Reply #21 on: October 19, 2013, 01:02:21 am »
Thank very much for this! I used it to add Phone number and web.

It doesn't work when a user goes back to edit them though.  It does work when I edit it in admin.

Please can you help?

plesk

  • Full Member
  • ***
  • Posts: 188
Re: Add Phone Number and other field for Bender Theme
« Reply #22 on: October 27, 2013, 06:51:36 pm »
hello

I use the themes I have not France that item-sidebar.php file and the line item-post.php
how? thank you
<div class="control-group">
                                 <label class="control-label" for="contactEmail"> <php _e? ('E-mail', 'bender')> </ label>
                                 <div class = "contrôles"> <ItemForm php? Contact_email_text :: ()> </ div>

plesk

  • Full Member
  • ***
  • Posts: 188
Re: Add Phone Number and other field for Bender Theme
« Reply #23 on: October 28, 2013, 02:21:19 am »

lexosc

  • Sr. Member
  • ****
  • Posts: 344

shamim_biplob

  • Full Member
  • ***
  • Posts: 169
Re: Add Phone Number and other field for Bender Theme
« Reply #25 on: October 28, 2013, 09:14:39 am »
find in item-sidebar.php

Code: [Select]
<?php if( osc_item_show_email() ) { ?>
                <p class="email"><?php printf(__('E-mail: %s''bender'), osc_item_contact_email()); ?></p>
            <?php ?>
For phone number hide ad the following code bellow this code in item-sidebar.php (or wherever you want)
Code: [Select]
<?php if ( osc_item_contact_phone() ) { ?>
<div><button>Click for Mobile Number</button>      <p style="display: none"> <img src="<?php echo osc_current_web_theme_url('images/tel.png') ; ?>" alt="" title="custom_fields" style="float:left; margin-right:4px; margin-top:0px;">
 <?php echo osc_item_contact_phone(); ?></p>
        <script>$("button").click(function () {  $("p").show("slow");  $(this).hide();});</script></div>
            <?php ?>

and attachment image in your theme image folder

you can also change itemAction.php if you want.(remember this is core file and all change will be gone after update.)

find code
Code: [Select]
        if($aItem['userId'] != '') {
                    $user = User::newInstance()->findByPrimaryKey( $aItem['userId'] );
                    $aItem['userId']      = $aItem['userId'];
                    $aItem['contactName'] = $user['s_name'];
                    $aItem['contactEmail'] = $user['s_email'];

replace with
Code: [Select]
        if($aItem['userId'] != '') {
                    $user = User::newInstance()->findByPrimaryKey( $aItem['userId'] );
                    $aItem['userId']      = $aItem['userId'];
                    $aItem['contactName'] = $user['s_name'];
                    $aItem['contactEmail'] = $user['s_email'];
                    $aItem['contactPhone'] = ($user['s_phone_mobile'])? $user['s_phone_mobile'] : $user['s_phone_land'];





can anyone help us about this topic?

http://forums.osclass.org/general-help/refine-location-like-refine-category

plesk

  • Full Member
  • ***
  • Posts: 188
Re: Add Phone Number and other field for Bender Theme
« Reply #26 on: October 28, 2013, 10:53:29 pm »
good evening
weird is the line the other I can not find

I have not the line <p class="name"> <osc_item_contact_name php echo ()?> <p>


Code: [Select]
Part 2 Modify Themes

2.1 Modify oc-content/themes/bender/item-sidebar.php
under
Code: [Select]
                <h2><?php _e("Contact publisher"'bender'); ?></h2>
                <p class="name"><?php echo osc_item_contact_name(); ?><p>
add this to show phone number
Code: [Select]
                $phoneuser = osc_item_contact_phone();
                if ($phoneuser != "") { ?>
                        <p>Phone: <?php echo $phoneuser?></p>
                <?php ?>


I am not here understands what I do right? I am French

if can be

I have found this code
<? php if (osc_item_user_id () == null) {>
                                     <div class="input-has-placeholder input-separate-top">
                                         <label> <php _e ('Phone');?> </ label>
                                         <php ItemForm :: contact_phone_text ();?>
                                     </ div>
                                 <? php}>

So if I understand I renplacer by one the is his?

<div>
                                         <label> <php _e ('sometext');?> </ label>
                                         <php ItemForm :: sometext_text ();?>
                                     </ div>

or do you have any picture that I understand better

thank you


Code: [Select]
Part 3: to add other field

We can follow tutorial Part1 and Part2 above to add other text field, with very little differences below.
I can explain in detail. It must be adjusted according to your need.

3.1 at oc-admin/themes/modern/items/frm.php
We don't need "if (osc_item_user_id() == null) so change
Code: [Select]
                                <?php if( osc_item_user_id() == null ) { ?>
                                    <div class="input-has-placeholder input-separate-top">
                                        <label><?php _e('Phone'); ?></label>
                                        <?php ItemForm::contact_phone_text(); ?>
                                    </div>
                                <?php ?>
to
Code: [Select]
                                    <div>
                                        <label><?php _e('Sometext'); ?></label>
                                        <?php ItemForm::sometext_text(); ?>
                                    </div>
and place it where you want to add this field.

3.2 at oc-content/themes/bender/item-post.php
Place it outside Seller Info.
If you place <?php ItemForm::some_text(); ?> at Seller Info, it will only appear for non registered user.

3.3 be carefull at ItemActions.php
You must put your code outside "if" condition.
Adjust it according to your need.

3.4 for Buy / Sell option
For buy sell option you can use this field at struct.sql
Code: [Select]
    e_newused ENUM('NEW', 'USED') NOT NULL DEFAULT 'NEW',
and adjust your code.

plesk

  • Full Member
  • ***
  • Posts: 188
Re: Add Phone Number and other field for Bender Theme
« Reply #27 on: November 01, 2013, 09:22:30 pm »
hello to the other topics moden France etc. thank you

govind129

  • Newbie
  • *
  • Posts: 11
Re: Add Phone Number and other field for Bender Theme
« Reply #28 on: February 01, 2014, 04:16:28 pm »
help
only non registered user's mobile number is saving in database
and registered user's not
please help me

abatahir

  • Newbie
  • *
  • Posts: 21
Re: Add Phone Number and other field for Bender Theme
« Reply #29 on: February 10, 2014, 10:21:35 pm »
I am  using bender theme. I find <div class="control-group">
                                <label class="control-label" for="contactName"><?php _e('Name', 'bender'); ?></label>
                                <div class="controls">
                                    <?php ItemForm::contact_name_text(); ?>
                                </div>
                            </div>   

for name i want like this for phone number ... any one can help me.