Loading


Advertisement:

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

byteGator

  • Osclass Hero
  • Sr. Member
  • *
  • Posts: 346
  • Simple Mind is a Beautiful Mind
Add Phone Number and other field for Bender Theme
« on: September 15, 2013, 03:28:36 am »
To add phone number, we can use custom fields.
But we can also add this field by modify the oc_t_items database.
This is what we must do to add phone number for unregistered user:

Part 1: Modify core

1.1 Modify oc_t_items, add s_contact_phone
see attachment

1.2 Modify oc-include/osclass/installer/struct.sql
add :  s_contact_phone VARCHAR(45) NULL
Code: [Select]
CREATE TABLE /*TABLE_PREFIX*/t_item (
    pk_i_id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
    fk_i_user_id INT(10) UNSIGNED NULL,
    fk_i_category_id INT(10) UNSIGNED NOT NULL,
    dt_pub_date DATETIME NOT NULL,
    dt_mod_date DATETIME NULL,
    f_price FLOAT NULL,
    i_price BIGINT(20) NULL,
    fk_c_currency_code CHAR(3) NULL,
    s_contact_name VARCHAR(100) NULL,
    s_contact_email VARCHAR(140) NULL,
    s_contact_phone VARCHAR(45) NULL,        <------------ add this line
    s_ip VARCHAR(64) NOT NULL DEFAULT '',
    b_premium TINYINT(1) NOT NULL DEFAULT 0,
    b_enabled TINYINT(1) NOT NULL DEFAULT 1,
    b_active TINYINT(1) NOT NULL DEFAULT 0,
    b_spam TINYINT(1) NOT NULL DEFAULT 0,
    s_secret VARCHAR(40) NULL,
    b_show_email TINYINT(1) NULL,
    dt_expiration datetime NOT NULL DEFAULT '9999-12-31 23:59:59',

1.3 Modify oc-includes/osclass/model/item.php
add: s_contact_phone
Code: [Select]
        function __construct()
        {
            parent::__construct();
            $this->setTableName('t_item');
            $this->setPrimaryKey('pk_i_id');
            $array_fields = array(
                'pk_i_id',
                'fk_i_user_id',
                'fk_i_category_id',
                'dt_pub_date',
                'dt_mod_date',
                'f_price',
                'i_price',
                'fk_c_currency_code',
                's_contact_name',
                's_contact_email',
                's_contact_phone', <---------------- add this line
                'b_premium',
                's_ip',
                'b_enabled',
                'b_active',
                'b_spam',
                's_secret',
                'b_show_email',
                'dt_expiration'
            );
            $this->setFields($array_fields);
        }

1.4 Modify oc-includes/osclass/helpers/hitems.php
Add new function
Code: [Select]
    function osc_item_contact_phone() {
        return (string) osc_item_field("s_contact_phone");
    }

1.5 Modify oc-includes/osclass/helpers/hpremium.php
Add new function
Code: [Select]
    function osc_premium_contact_phone() {
        return (string) osc_premium_field("s_contact_phone");
    }

1.6 Modify oc-includes/osclass/ItemActions.php
1.6.1 at add()
modify from
Code: [Select]
            $contactName       = strip_tags( trim( $aItem['contactName'] ) );
            $contactEmail      = strip_tags( trim( $aItem['contactEmail'] ) );
            $aItem['cityArea'] = osc_sanitize_name( strip_tags( trim( $aItem['cityArea'] ) ) );
            $aItem['address']  = osc_sanitize_name( strip_tags( trim( $aItem['address'] ) ) );
to
Code: [Select]
            $contactName       = strip_tags( trim( $aItem['contactName'] ) );
            $contactEmail      = strip_tags( trim( $aItem['contactEmail'] ) );
            $contactPhone      = strip_tags( trim( $aItem['contactPhone'] ) );
            $aItem['cityArea'] = osc_sanitize_name( strip_tags( trim( $aItem['cityArea'] ) ) );
            $aItem['address']  = osc_sanitize_name( strip_tags( trim( $aItem['address'] ) ) );

And from:
Code: [Select]
                $this->manager->insert(array(
                    'fk_i_user_id'          => $aItem['userId'],
                    'dt_pub_date'           => date('Y-m-d H:i:s'),
                    'fk_i_category_id'      => $aItem['catId'],
                    'i_price'               => $aItem['price'],
                    'fk_c_currency_code'    => $aItem['currency'],
                    's_contact_name'        => $contactName,
                    's_contact_email'       => $contactEmail,
                    's_secret'              => $code,
                    'b_active'              => ($active=='ACTIVE'?1:0),
                    'b_enabled'             => $enabled,
                    'b_show_email'          => $aItem['showEmail'],
                    'b_spam'                => $is_spam,
                    's_ip'                  => $aItem['s_ip']
                ));
to
Code: [Select]
                $this->manager->insert(array(
                    'fk_i_user_id'          => $aItem['userId'],
                    'dt_pub_date'           => date('Y-m-d H:i:s'),
                    'fk_i_category_id'      => $aItem['catId'],
                    'i_price'               => $aItem['price'],
                    'fk_c_currency_code'    => $aItem['currency'],
                    's_contact_name'        => $contactName,
                    's_contact_email'       => $contactEmail,
                    's_contact_phone'       => $contactPhone,
                    's_secret'              => $code,
                    'b_active'              => ($active=='ACTIVE'?1:0),
                    'b_enabled'             => $enabled,
                    'b_show_email'          => $aItem['showEmail'],
                    'b_spam'                => $is_spam,
                    's_ip'                  => $aItem['s_ip']
                ));

and from
Code: [Select]
            $_meta = Field::newInstance()->findByCategory($aItem['catId']);
            $meta = Params::getParam("meta");
to
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 : '' );
           
            $_meta = Field::newInstance()->findByCategory($aItem['catId']);
            $meta = Params::getParam("meta");

1.6.2 at edit()
modify from:
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'];
                } else {
                    $aItem['userId']      = NULL;
                }
to
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'];
                } else {
                    $aItem['userId']      = NULL;
                }

and from:
Code: [Select]
                if( $this->is_admin ) {
                    $aUpdate['fk_i_user_id']    = $aItem['userId'];
                    $aUpdate['s_contact_name']  = $aItem['contactName'];
                    $aUpdate['s_contact_email'] = $aItem['contactEmail'];
                } else {
                    $aUpdate['s_ip'] = $aItem['s_ip'];
                }
to
Code: [Select]
                if( $this->is_admin ) {
                    $aUpdate['fk_i_user_id']    = $aItem['userId'];
                    $aUpdate['s_contact_name']  = $aItem['contactName'];
                    $aUpdate['s_contact_email'] = $aItem['contactEmail'];
                    $aUpdate['s_contact_phone'] = $aItem['contactPhone'];
                } else {
                    $aUpdate['s_ip'] = $aItem['s_ip'];
                }

and from
Code: [Select]
            $_meta = Field::newInstance()->findByCategory($aItem['catId']);
            $meta = Params::getParam("meta");
to
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 : '' );
           
            $_meta = Field::newInstance()->findByCategory($aItem['catId']);
            $meta = Params::getParam("meta");

1.6.3 at preparedata()
from:
Code: [Select]
            if($userId != null) {
                $aItem['contactName']   = $data['s_name'];
                $aItem['contactEmail']  = $data['s_email'];
                Params::setParam('contactName', $data['s_name']);
                Params::setParam('contactEmail', $data['s_email']);
            } else {
                $aItem['contactName']   = Params::getParam('contactName');
                $aItem['contactEmail']  = Params::getParam('contactEmail');
            }
to
Code: [Select]
            if($userId != null) {
                $aItem['contactName']   = $data['s_name'];
                $aItem['contactEmail']  = $data['s_email'];
                $aItem['contactPhone']  = ($data['s_phone_mobile'])? $data['s_phone_mobile'] : $data['s_phone_land'];
                Params::setParam('contactName', $data['s_name']);
                Params::setParam('contactEmail', $data['s_email']);
                Params::setParam('contactPhone', ($data['s_phone_mobile'])? $data['s_phone_mobile'] : $data['s_phone_land']);
            } else {
                $aItem['contactName']   = Params::getParam('contactName');
                $aItem['contactEmail']  = Params::getParam('contactEmail');
                $aItem['contactPhone']  = Params::getParam('contactPhone');
            }

1.7 Modify oc-includes/osclass/frm/item.form.class.php
add function contact_phone_text()
Code: [Select]
        static public function contact_phone_text($item = null) {
            if($item==null) { $item = osc_item(); };
            if( Session::newInstance()->_getForm('contactPhone') != "" ) {
                $item['s_contact_phone'] = Session::newInstance()->_getForm('contactPhone');
            }
            parent::generic_input_text('contactPhone', (isset($item['s_contact_phone'])) ? $item['s_contact_phone'] : null);
            return true;
        }

continue..........
« Last Edit: October 15, 2013, 09:09:04 am by byteGator »

strata

  • Sr. Member
  • ****
  • Posts: 411
  • Always good, always...
Re: Add Phone Number field for Bender Theme
« Reply #1 on: September 15, 2013, 03:32:07 am »
Waiting for the next part bro (ane tunggu kelanjutannya gan)...salam kenal ya bang :)

byteGator

  • Osclass Hero
  • Sr. Member
  • *
  • Posts: 346
  • Simple Mind is a Beautiful Mind
Re: Add Phone Number field for Bender Theme
« Reply #2 on: September 15, 2013, 03:46:48 am »
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 ?>

2.2 Modify oc-content/themes/bender/item-post.php
below email field.
Code: [Select]
                            <div class="control-group">
                                <label class="control-label" for="contactEmail"><?php _e('E-mail''bender'); ?></label>
                                <div class="controls">
                                <?php ItemForm::contact_email_text(); ?>
                                </div>
                            </div>
add phone field.
Code: [Select]
                            <div class="control-group">
                                <label class="control-label" for="contactEmail"><?php _e('E-mail''bender'); ?></label>
                                <div class="controls">
                                <?php ItemForm::contact_email_text(); ?>
                                </div>
                            </div>

                            <div class="control-group">
                                <label class="control-label" for="contactPhone"><?php _e('Phone''bender'); ?></label>
                                <div class="controls">
                                <?php ItemForm::contact_phone_text(); ?>
                                </div>
                            </div>

2.3 Modify oc-admin/themes/modern/items/frm.php
below
Code: [Select]
                                <div class="input-has-placeholder input-separate-top">
                                    <label><?php _e('E-mail'); ?></label>
                                    <?php ItemForm::contact_email_text(); ?>
                                </div>
add phone field.
Code: [Select]
                                <div class="input-has-placeholder input-separate-top">
                                    <label><?php _e('E-mail'); ?></label>
                                    <?php ItemForm::contact_email_text(); ?>
                                </div>

                                <?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 ?>

« Last Edit: September 15, 2013, 03:58:38 am by byteGator »

byteGator

  • Osclass Hero
  • Sr. Member
  • *
  • Posts: 346
  • Simple Mind is a Beautiful Mind
Re: Add Phone Number and other field for Bender Theme
« Reply #3 on: September 15, 2013, 04:02:00 am »
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.
« Last Edit: September 15, 2013, 04:57:57 pm by byteGator »

byteGator

  • Osclass Hero
  • Sr. Member
  • *
  • Posts: 346
  • Simple Mind is a Beautiful Mind
Re: Add Phone Number field for Bender Theme
« Reply #4 on: September 15, 2013, 04:52:18 am »
Waiting for the next part bro (ane tunggu kelanjutannya gan)...salam kenal ya bang :)

Thank you

TheDeadLives

  • Sr. Member
  • ****
  • Posts: 279
Re: Add Phone Number and other field for Bender Theme
« Reply #5 on: September 15, 2013, 06:44:15 pm »
Quote
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.

Thanks for sharing it.

If you want to create a phone field for non-registered users with a checkbox to hide/show phone in item.php see here the code

http://forums.osclass.org/development/new-field-in-item-post-php-help

TheDeadLives

  • Sr. Member
  • ****
  • Posts: 279
Re: Add Phone Number and other field for Bender Theme
« Reply #6 on: September 15, 2013, 10:56:57 pm »
At your themes folder, go to item-post.php and add this code where you want the box for contact phone to appear (in this version, the code has a button for hide or show the contact phone in the item page):

Code: [Select]
<div class="row">
                            <label for="contactPhone"><?php _e('Phone''modern'); ?> *</label>
                            <?php ItemForm::contact_phone_text(); ?>
                        </div>
                          <div class="row">
                            <div style="width: 120px;text-align: right;float:left;">
                                <?php ItemForm::show_phone_checkbox(); ?>
                            </div>
                             <label for="showPhone" style="width: 250px;"><?php _e('Show e-mail on the listing page''modern'); ?></label>
                        </div>

Go to you themes folder, item.php and add this where you want the contact phone to appear:

Code: [Select]
<?php if( osc_item_show_phone() ) { ?>
                            <p class="phone"><?php _e('Phone''modern'); ?>: <?php echo osc_item_contact_phone(); ?></p>
                        <?php ?>

Now, the hard part. Go to osclass/oc-includes/osclass/frm and open Item.form.class.php. Add:

Code: [Select]
static public function contact_phone_text($item = null) {
            if($item==null) { $item = osc_item(); };
            if( Session::newInstance()->_getForm('contactPhone') != "" ) {
                $item['s_contact_phone'] = Session::newInstance()->_getForm('contactPhone');
            }
            parent::generic_input_text('contactPhone', (isset($item['s_contact_phone'])) ? $item['s_contact_phone'] : null);
            return true;
        }
static public function show_phone_checkbox($item = null) {
            if($item==null) { $item = osc_item(); };
            if( Session::newInstance()->_getForm('showPhone') != 0) {
                $item['b_show_phone'] = Session::newInstance()->_getForm('showPhone');
            }
            parent::generic_input_checkbox('showPhone', '1', (isset($item['b_show_phone']) ) ? $item['b_show_phone'] : false );
            return true;
        }

Now go to osclass/oc-includes/osclass/ItemActions.php

Change this:

Code: [Select]
if($userId != null) {
                $aItem['contactName']   = $data['s_name'];
                $aItem['contactEmail']  = $data['s_email'];
                Params::setParam('contactName', $data['s_name']);
                Params::setParam('contactEmail', $data['s_email']);
            } else {
                $aItem['contactName']   = Params::getParam('contactName');
                $aItem['contactEmail']  = Params::getParam('contactEmail');
            }

For this:
Code: [Select]
if($userId != null) {
                $aItem['contactName']   = $data['s_name'];
                $aItem['contactEmail']  = $data['s_email'];
                Params::setParam('contactName', $data['s_name']);
                Params::setParam('contactEmail', $data['s_email']);
            } else {
                $aItem['contactName']   = Params::getParam('contactName');
                $aItem['contactEmail']  = Params::getParam('contactEmail');
$aItem['contactPhone']  = Params::getParam('contactPhone');
            }
This:

 
Code: [Select]
$aItem['price']    = !is_null($aItem['price']) ? strip_tags( trim( $aItem['price'] ) ) : $aItem['price'];
            $contactName       = osc_sanitize_name( strip_tags( trim( $aItem['contactName'] ) ) );
            $contactEmail      = strip_tags( trim( $aItem['contactEmail'] ) );
            $aItem['cityArea'] = osc_sanitize_name( strip_tags( trim( $aItem['cityArea'] ) ) );
            $aItem['address']  = osc_sanitize_name( strip_tags( trim( $aItem['address'] ) ) );

For this:

Code: [Select]
$aItem['price']    = !is_null($aItem['price']) ? strip_tags( trim( $aItem['price'] ) ) : $aItem['price'];
            $contactName       = osc_sanitize_name( strip_tags( trim( $aItem['contactName'] ) ) );
            $contactEmail      = strip_tags( trim( $aItem['contactEmail'] ) );
$contactPhone      = strip_tags( trim( $aItem['contactPhone'] ) );
            $aItem['cityArea'] = osc_sanitize_name( strip_tags( trim( $aItem['cityArea'] ) ) );
            $aItem['address']  = osc_sanitize_name( strip_tags( trim( $aItem['address'] ) ) );

This:

Code: [Select]
'fk_i_user_id'          => $aItem['userId'],
                    'dt_pub_date'           => date('Y-m-d H:i:s'),
                    'fk_i_category_id'      => $aItem['catId'],
                    'i_price'               => $aItem['price'],
                    'fk_c_currency_code'    => $aItem['currency'],
                    's_contact_name'        => $contactName,
                    's_contact_email'       => $contactEmail,
                    's_secret'              => $code,
                    'b_active'              => ($active=='ACTIVE'?1:0),
                    'b_enabled'             => 1,
                    'b_show_email'          => $aItem['showEmail'],
                    's_ip'                  => $aItem['s_ip']

For this:

Code: [Select]
'fk_i_user_id'          => $aItem['userId'],
                    'dt_pub_date'           => date('Y-m-d H:i:s'),
                    'fk_i_category_id'      => $aItem['catId'],
                    'i_price'               => $aItem['price'],
                    'fk_c_currency_code'    => $aItem['currency'],
                    's_contact_name'        => $contactName,
                    's_contact_email'       => $contactEmail,
    's_contact_phone'       => $contactPhone,
                    's_secret'              => $code,
                    'b_active'              => ($active=='ACTIVE'?1:0),
                    'b_enabled'             => 1,
                    'b_show_email'          => $aItem['showEmail'],
    'b_show_phone'          => $aItem['showPhone'],
                    's_ip'                  => $aItem['s_ip']
This:

 
Code: [Select]
if( $this->is_admin ) {
                    $aUpdate['fk_i_user_id']    = $aItem['userId'];
                    $aUpdate['s_contact_name']  = $aItem['contactName'];
                    $aUpdate['s_contact_email'] = $aItem['contactEmail'];
                } else {
                    $aUpdate['s_ip'] = $aItem['s_ip'];
                }

For this:

Code: [Select]
  if( $this->is_admin ) {
                    $aUpdate['fk_i_user_id']    = $aItem['userId'];
                    $aUpdate['s_contact_name']  = $aItem['contactName'];
                    $aUpdate['s_contact_email'] = $aItem['contactEmail'];
                    $aUpdate['s_contact_phone'] = $aItem['contactPhone'];
                } else {
                    $aUpdate['s_ip'] = $aItem['s_ip'];
                }

Now in osclass/oc-includes/osclass/installer/struct.sql. Modify this:

Code: [Select]
CREATE TABLE /*TABLE_PREFIX*/t_item (
    pk_i_id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
    fk_i_user_id INT(10) UNSIGNED NULL,
    fk_i_category_id INT(10) UNSIGNED NOT NULL,
    dt_pub_date DATETIME NOT NULL,
    dt_mod_date DATETIME NULL,
    f_price FLOAT NULL,
    i_price BIGINT(20) NULL,
    fk_c_currency_code CHAR(3) NULL,
    s_contact_name VARCHAR(100) NULL,
    s_contact_email VARCHAR(140) NULL,
    s_ip VARCHAR(64) NOT NULL DEFAULT '',
    b_premium TINYINT(1) NOT NULL DEFAULT 0,
    b_enabled TINYINT(1) NOT NULL DEFAULT 1,
    b_active TINYINT(1) NOT NULL DEFAULT 0,
    b_spam TINYINT(1) NOT NULL DEFAULT 0,
    s_secret VARCHAR(40) NULL,
    b_show_email TINYINT(1) NULL,
    dt_expiration datetime NOT NULL DEFAULT '9999-12-31 23:59:59',

        PRIMARY KEY (pk_i_id),
        FOREIGN KEY (fk_i_user_id) REFERENCES /*TABLE_PREFIX*/t_user (pk_i_id),
        FOREIGN KEY (fk_i_category_id) REFERENCES /*TABLE_PREFIX*/t_category (pk_i_id),
        FOREIGN KEY (fk_c_currency_code) REFERENCES /*TABLE_PREFIX*/t_currency (pk_c_code),

        INDEX (fk_i_user_id),
        INDEX idx_s_contact_email (s_contact_email(10)),
        INDEX (fk_i_category_id),
        INDEX (fk_c_currency_code),
        INDEX idx_pub_date (dt_pub_date),
        INDEX idx_price (i_price)
) ENGINE=InnoDB DEFAULT CHARACTER SET 'UTF8' COLLATE 'UTF8_GENERAL_CI';

For this:

Code: [Select]
CREATE TABLE /*TABLE_PREFIX*/t_item (
    pk_i_id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
    fk_i_user_id INT(10) UNSIGNED NULL,
    fk_i_category_id INT(10) UNSIGNED NOT NULL,
    dt_pub_date DATETIME NOT NULL,
    dt_mod_date DATETIME NULL,
    f_price FLOAT NULL,
    i_price BIGINT(20) NULL,
    fk_c_currency_code CHAR(3) NULL,
    s_contact_name VARCHAR(100) NULL,
    s_contact_email VARCHAR(140) NULL,
    s_contact_phone VARCHAR(15) NULL,
    s_ip VARCHAR(64) NOT NULL DEFAULT '',
    b_premium TINYINT(1) NOT NULL DEFAULT 0,
    b_enabled TINYINT(1) NOT NULL DEFAULT 1,
    b_active TINYINT(1) NOT NULL DEFAULT 0,
    b_spam TINYINT(1) NOT NULL DEFAULT 0,
    s_secret VARCHAR(40) NULL,
    b_show_email TINYINT(1) NULL,
    b_show_phone TINYINT(1) NULL,
    dt_expiration datetime NOT NULL DEFAULT '9999-12-31 23:59:59',

        PRIMARY KEY (pk_i_id),
        FOREIGN KEY (fk_i_user_id) REFERENCES /*TABLE_PREFIX*/t_user (pk_i_id),
        FOREIGN KEY (fk_i_category_id) REFERENCES /*TABLE_PREFIX*/t_category (pk_i_id),
        FOREIGN KEY (fk_c_currency_code) REFERENCES /*TABLE_PREFIX*/t_currency (pk_c_code),

        INDEX (fk_i_user_id),
        INDEX idx_s_contact_email (s_contact_email(10)),
        INDEX (fk_i_category_id),
        INDEX (fk_c_currency_code),
        INDEX idx_pub_date (dt_pub_date),
        INDEX idx_price (i_price)
) ENGINE=InnoDB DEFAULT CHARACTER SET 'UTF8' COLLATE 'UTF8_GENERAL_CI';

In helpers, open hPreference.php. And add:

Code: [Select]
function osc_contact_phone() {
        return(getPreference('contactPhone'));
    }

And, still in the helpers paste, open hItems.php and add this:

Code: [Select]
function osc_item_show_phone() {
        return (boolean) osc_item_field("b_show_phone");
    }

Very IMPORTANT - go to your themes folder and open style.css Add this code:

Code: [Select]
.add_item input#showPhone { border:1px solid #BBB; padding:7px 7px 6px; width:20px; }

alexgr

  • Sr. Member
  • ****
  • Posts: 328
Re: Add Phone Number and other field for Bender Theme
« Reply #7 on: October 01, 2013, 07:26:28 pm »
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 ?

blue_man

  • Newbie
  • *
  • Posts: 1
Re: Add Phone Number and other field for Bender Theme
« Reply #8 on: October 08, 2013, 08:48:04 pm »
I made the changes specified, but can not add ads. I using version 3.2.1.
Rhank you all

rahulk

  • Full Member
  • ***
  • Posts: 127
  • What we face is destiny, how we face is free will.
Re: Add Phone Number and other field for Bender Theme
« Reply #9 on: October 12, 2013, 07:41:01 pm »
Hello byteGator

Can you share code for browsing categories with subcategories like this site http://iklangratis.org/

I am using osclass 3.2.1 with default bender theme.

Thank you!
« Last Edit: October 12, 2013, 07:42:57 pm by rahulk »

shamim_biplob

  • Full Member
  • ***
  • Posts: 169
Re: Add Phone Number and other field for Bender Theme
« Reply #10 on: October 13, 2013, 01:48:18 am »
how can i make phone field required (server side validation)?
please help me.

byteGator

  • Osclass Hero
  • Sr. Member
  • *
  • Posts: 346
  • Simple Mind is a Beautiful Mind
Re: Add Phone Number and other field for Bender Theme
« Reply #11 on: October 14, 2013, 03:11:16 am »
Hello byteGator

Can you share code for browsing categories with subcategories like this site http://iklangratis.org/

I am using osclass 3.2.1 with default bender theme.

Thank you!

Hi rahulk,

I don't know what you mean. Need more explaination.

byteGator

  • Osclass Hero
  • Sr. Member
  • *
  • Posts: 346
  • Simple Mind is a Beautiful Mind
Re: Add Phone Number and other field for Bender Theme
« Reply #12 on: October 14, 2013, 03:26:11 am »
how can i make phone field required (server side validation)?
please help me.

Hi shamim_biplob
nice catch.

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['contactPhone'], 7, false)) ? _m("Phone Number too short.") . PHP_EOL : '' ) .
                ((!osc_validate_max($aItem['contactPhone'], 20)) ? _m("Phone Number too long.") . PHP_EOL : '' );
           
            $_meta = Field::newInstance()->findByCategory($aItem['catId']);
            $meta = Params::getParam("meta");
« Last Edit: October 15, 2013, 09:11:37 am by byteGator »

byteGator

  • Osclass Hero
  • Sr. Member
  • *
  • Posts: 346
  • Simple Mind is a Beautiful Mind
Re: Add Phone Number and other field for Bender Theme
« Reply #13 on: October 14, 2013, 06:22:13 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 ?

hi alexgr

I have answer it in :

http://forums.osclass.org/themes/%28tips%29-how-to-hide-last-4-digit-phone-number/msg71105

shamim_biplob

  • Full Member
  • ***
  • Posts: 169
Re: Add Phone Number and other field for Bender Theme
« Reply #14 on: October 14, 2013, 01:13:01 pm »
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.