Osclass forums
Development => Themes => Topic started by: byteGator 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
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
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
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
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
$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
$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:
$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
$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
$_meta = Field::newInstance()->findByCategory($aItem['catId']);
$meta = Params::getParam("meta");
to
$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:
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
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:
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
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
$_meta = Field::newInstance()->findByCategory($aItem['catId']);
$meta = Params::getParam("meta");
to
$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:
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
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()
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..........
-
Waiting for the next part bro (ane tunggu kelanjutannya gan)...salam kenal ya bang :)
-
Part 2 Modify Themes
2.1 Modify oc-content/themes/bender/item-sidebar.php
under
<h2><?php _e("Contact publisher", 'bender'); ?></h2>
<p class="name"><?php echo osc_item_contact_name(); ?><p>
add this to show phone number
$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.
<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.
<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
<div class="input-has-placeholder input-separate-top">
<label><?php _e('E-mail'); ?></label>
<?php ItemForm::contact_email_text(); ?>
</div>
add phone field.
<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 } ?>
-
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
<?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
<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
e_newused ENUM('NEW', 'USED') NOT NULL DEFAULT 'NEW',
and adjust your code.
-
Waiting for the next part bro (ane tunggu kelanjutannya gan)...salam kenal ya bang :)
Thank you
-
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 (http://forums.osclass.org/development/new-field-in-item-post-php-help)
-
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):
<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:
<?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:
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:
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:
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:
$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:
$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:
'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:
'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:
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:
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:
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:
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:
function osc_contact_phone() {
return(getPreference('contactPhone'));
}
And, still in the helpers paste, open hItems.php and add this:
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:
.add_item input#showPhone { border:1px solid #BBB; padding:7px 7px 6px; width:20px; }
-
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 ?
-
I made the changes specified, but can not add ads. I using version 3.2.1.
Rhank you all
-
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!
-
how can i make phone field required (server side validation)?
please help me.
-
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.
-
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
$_meta = Field::newInstance()->findByCategory($aItem['catId']);
$meta = Params::getParam("meta");
add this
$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");
-
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
-
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.
-
At ItemAction.php, function add() and edit(), above
$_meta = Field::newInstance()->findByCategory($aItem['catId']);
$meta = Params::getParam("meta");
add this
$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.
$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.
-
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.
-
At ItemAction.php, function add() and edit(), above
$_meta = Field::newInstance()->findByCategory($aItem['catId']);
$meta = Params::getParam("meta");
add this
$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.
$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'
$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 : '' );
-
Hi shamim_biplob
Sorry, I made a mistake.
Please change 's_contact_phone' to 'contactPhone'
$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?
-
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:
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:
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>';
}
-
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?
<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>
<div id="textleft">250 characters left</div>
-
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?
-
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>
-
you like this type of phone number hide?
http://www.banglardokan.com/electronics/laptopstablets/dell-vostro-1014-i4521
-
you like this type of phone number hide?
http://www.banglardokan.com/electronics/laptopstablets/dell-vostro-1014-i4521
how did you do that?
-
find in item-sidebar.php
<?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)
<?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 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 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
-
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>
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
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.
-
hello to the other topics moden France etc. thank you
-
help
only non registered user's mobile number is saving in database
and registered user's not
please help me
-
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.
-
Hello everyone,
Fields telephone does not appear for the users registered student
How can I show it fields (for the addition of an announcement)?
Thanks for your answers
Regards
-
Hello everyone! I need some help here... I don't know exactly what went wrong, the item sidebar disappears and i get the following error: Parse error: syntax error, unexpected '}' in /oc-content/themes/bender/item-sidebar.php on line 45
Any clues??
-
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>
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
In Osclass 3.3.2, in line 59 approximately
<?php if( osc_item_user_id() != null ) { ?>
<p class="name"><?php _e('Name', 'bender') ?>: <a href="<?php echo osc_user_public_profile_url( osc_item_user_id() ); ?>" ><?php echo osc_item_contact_name(); ?></a></p>
<?php $phoneuser = osc_item_contact_phone();
if ($phoneuser != "") { ?>
<p>Phone: <?php echo $phoneuser; ?></p>
<?php } ?>
add <?php before $phoneuser
-
Thank you :)
-
I think phone number filed for non registered users is a necessity - and should be added in the next update of osclass!
-
Hello everyone! I need some help here... I don't know exactly what went wrong, the item sidebar disappears and i get the following error: Parse error: syntax error, unexpected '}' in /oc-content/themes/bender/item-sidebar.php on line 45
Any clues??
You missing the closing bracket
<?php } ?>
-
I used this guide to create both a phone number field and a confirm email field. Followed it exactly. It works for confirm email but not the phone number..
The problem is, no matter what I do, the phone number field is turning up null.
Any guesses?
-
Hi, how I can insert the new table (number phone) manually in my database backup? Somebody can explain set by step, please?
Regards
-
@ADMIN make sticky this post please
-
Hello I very like this mod,
But I want to know is there any way to achieve it without modifying the core?
If I apply the changes now and then I update osclass will my site function correctly?
Thanks
-
Hi byteGator,
Your website, iklangratis.net use bender theme with custom code right? Can you share with us? It's really good to have one like yours.
-
Hi byteGator,
I have added the phone number field following the exact steps you have indicated. Everything works fine, i can add the phone number when i post a new ad, but the number does not appear in the sidebar as expected. Also, i get an error (please see attachment) instead of the registered user phone number. I'm using version v 3.2.2 where the instructions and the code in item-sidebar.php are a little bit different from what you have posted.
Please can you help me to correct this problem?
Thank you. :)
-
Hello,
Why everyone here editing theme for phone number when you can easily add Custom fields on manage listings menu ?
-
Hi byteGator,
I have added the phone number field following the exact steps you have indicated. Everything works fine, i can add the phone number when i post a new ad, but the number does not appear in the sidebar as expected. Also, i get an error (please see attachment) instead of the registered user phone number. I'm using version v 3.2.2 where the instructions and the code in item-sidebar.php are a little bit different from what you have posted.
Please can you help me to correct this problem?
Thank you. :)
Ohh... c'mon nobody knows how to add in item-sidebar a phone number for unregistered users?
I don't want to use custom fields for contact info, i use custom fields for other specific info for the item on sale.
I'm stuck with this problem for over a month.
I have tried the solution posted a the beginning of this thread but it does not work in 3.4.1.
Help? :)
-
Hi, nice tutorial, plz explan how add radio buttons add item-post page. (Without custem feild), thanks.
-
Hi byteGator,
I am inspired by your procedures of adding phone number.
I am working on WAMP server to make the editing.
I followed your steps perfectly but after the editing whenever an ad is published it is never displayed.
This started occurring when i edited the itermAction.php following your steps.
Please help me correct this problem
-
Hello byte
I have done all the steps, but when ads are submitted they are never displayed or saved
Please help me on this .
It started happening when I made changes to itermAction.php following your procedure.
Thanks for your cooperation
-
@byteGator,
This turotial works with osclass 3.4 ? :o
-
Hi All,
How can user change mobile number after publish post as unregisterd user
pls reply me soon as possible
-
Hello,
how to add phone and registered?
Not every registered user add numbers to your account.
-
Is there no one to help?
-
Great Work !
Thanks
dp @ clickadd.in (http://clickadd.in)
-
hi.. could anyone help me with this.. i did all the steps and everything looks ok but when i post an ad and ticket to show phone number it doesnt show on the ad.. but in item-sidebar.php if i change this osc_item_show_phone to osc_item_contact_phone it shows the phone number but i need the ticket box working.. this is the code:
<div class="widget-box">
<h3><?php _e("Publisher", 'azul'); ?></h3>
<?php if( osc_item_user_id() != null ) { ?>
<p class="name"><img src="https://cdn3.iconfinder.com/data/icons/wpzoom-developer-icon-set/500/88-16.png" style="opacity:0.6" /> <a href="<?php echo osc_user_public_profile_url( osc_item_user_id() ); ?>" ><?php echo osc_item_contact_name(); ?></a></p>
<?php } else { ?>
<p class="name"><img src="https://cdn3.iconfinder.com/data/icons/wpzoom-developer-icon-set/500/88-16.png" style="opacity:0.6" /> <?php echo osc_item_contact_name(); ?></p>
<?php } ?>
<?php if ( osc_user_phone() != '' ) { ?>
<p class="phone"><img src="https://cdn4.iconfinder.com/data/icons/aiga-symbol-signs/613/aiga_telephone_bg-16.png" style="opacity:0.6" /> <?php echo osc_user_phone(); ?></p>
<?php } ?>
<?php if( osc_item_show_phone() ) { ?>
<p class="contactphone"><img src="https://cdn4.iconfinder.com/data/icons/pictype-free-vector-icons/16/contact-16.png" style="opacity:0.6" /> <?php echo osc_item_contact_phone(); ?></p>
<?php } ?>
<?php if( osc_item_show_email() ) { ?>
<p class="email"><img src="https://cdn4.iconfinder.com/data/icons/pictype-free-vector-icons/16/contact-16.png" style="opacity:0.6" /> <?php echo osc_item_contact_email(); ?></p>
<?php } ?>
</div>
-
To resolve the problem, phone number requeried.
<input title="Need Phone Number" id="telephone" type="text" value="<?php echo $detail; ?>" name="telephone" required></input>
-
Hi,
I try to add extra fields on user register!
I find this code in oc-includes/osclass/helpers/hUsers.php
//can already be a logged user or not, we'll take a look into the cookie
if ( Cookie::newInstance()->get_value('oc_userId') != '' && Cookie::newInstance()->get_value('oc_userSecret') != '') {
$user = User::newInstance()->findByIdSecret( Cookie::newInstance()->get_value('oc_userId'), Cookie::newInstance()->get_value('oc_userSecret') );
View::newInstance()->_exportVariableToView('_loggedUser', $user);
if(isset($user['b_enabled']) && $user['b_enabled']==1) {
Session::newInstance()->_set('userId', $user['pk_i_id']);
Session::newInstance()->_set('userName', $user['s_name']);
Session::newInstance()->_set('userEmail', $user['s_email']);
$phone = ($user['s_phone_mobile'])? $user['s_phone_mobile'] : $user['s_phone_land'];
Session::newInstance()->_set('userPhone', $phone);
return true;
} else {
return false;
}
}
return false;
}
How to modify this ?
$phone = ($user['s_phone_mobile'])? $user['s_phone_mobile'] : $user['s_phone_land'];
Session::newInstance()->_set('userPhone', $phone);
we need 3 fields:
s_phone_verified
s_phone_mobile
s_phone_land
Thanks
-
Guys i'm a student and needs some help on this!
Is this right what i try?
The s_phone verified i use for RingCaptcha plugin on registration!
Than i have 2 extra fields s_phone_mobile and s_phone_land
if(!$this->is_admin) {
Session::newInstance()->_set('userName', $input['s_name']);
$phone = ($input['s_phone_verified'])? $input['s_phone_mobile'] : $input['s_phone_land'];
Session::newInstance()->_set('userPhone', $phone);
}
Thanks