Advertisement:

Author Topic: Add extra fields for contact publisher  (Read 3836 times)

keepdot

  • Newbie
  • *
  • Posts: 5
Add extra fields for contact publisher
« on: May 28, 2014, 04:27:26 pm »
how to Add extra fields for contact publisher  form in osclass, now i have only: neme, email, phone, massage. i want add more fields, and all that is sent in the mail to publisher.

design

  • Hero Member
  • *****
  • Posts: 2619
  • Osclass 3.5 MAC/PC w/ Modern Browsers
Re: Add extra fields for contact publisher
« Reply #1 on: May 28, 2014, 09:21:43 pm »
it is not as easy as you would like. because the script checks for many things in the fields before it goes live. not to mention the emails - spam filtering, email address checking.

you would have to extend your fields

here is the osclass method, you will need to modify it slightly , using the contact form and it's pathways.
http://doc.osclass.org/How_to_extend_fields

keepdot

  • Newbie
  • *
  • Posts: 5
Re: Add extra fields for contact publisher
« Reply #2 on: May 28, 2014, 10:57:36 pm »
I know how to make a plugin to add special attributes for ad, I do not know how you could do that these attributes are sent in the mail to contact publisher ? THX

my attempt, but it does not work. I'm going in the right direction ?

i use Osclass 3.3.2, real estate teme

to realestate/contact.php
Code: [Select]
<div class="row ui-row-text"><label for="contactmyField"><?php _e('contact myField''realestate') ; ?></label> <?php ContactForm::your_myField(); ?></div>
to oc-includes/osclass/controller/contact.php
Code: [Select]
36: $myField   = Params::getParam('myField');
45: Session::newInstance()->_setForm('myField', $myField);
71: Session::newInstance()->_setForm('myField', $myField);
79:  $message_myField = sprintf(__('My Field: %s'), $myField);
87: {$message_myField}

to oc-includes/osclass/emails.php
Code: [Select]
1053:  function fn_email_contact_user($id, $yourEmail, $yourName, $phoneNumber, $message, $myField) {
        $mPages = new Page();
        $aPage = $mPages->findByInternalName('email_contact_user');
        $locale = osc_current_user_locale();

        $content = array();
        if(isset($aPage['locale'][$locale]['s_title'])) {
            $content = $aPage['locale'][$locale];
        } else {
            $content = current($aPage['locale']);
        }

        $words   = array();
        $words[] = array(
            '{CONTACT_NAME}',
            '{USER_NAME}',
            '{USER_EMAIL}',
            '{USER_PHONE}',
         '{MY_FIELD}',
            '{COMMENT}'
        );
        $words[] = array(
            osc_user_name(),
            $yourName,
            $yourEmail,
            $phoneNumber,
            $message,
         $myField
        );

        $title = osc_apply_filter('email_item_inquiry_title_after', osc_mailBeauty(osc_apply_filter('email_title', osc_apply_filter('email_item_inquiry_title', $content['s_title'])), $words));
        $body = osc_apply_filter('email_item_inquiry_description_after', osc_mailBeauty(osc_apply_filter('email_description', osc_apply_filter('email_item_inquiry_description', $content['s_text'])), $words));

        $emailParams = array (
            'from'      => osc_contact_email(),
            'subject'   => $title,
            'to'        => osc_user_email(),
            'to_name'   => osc_user_name(),
            'body'      => $body,
            'alt_body'  => $body,
            'reply_to'  => $yourEmail
        );

        if( osc_notify_contact_item() ) {
            $emailParams['add_bcc'] = osc_contact_email();
        }

        osc_sendMail($emailParams);
    }
    osc_add_hook('hook_email_contact_user', 'fn_email_contact_user');

to oc-includes/osclass/frm/contact.for.class.php

Code: [Select]
90:    static public function your_myField() {
            if( Session::newInstance()->_getForm("myField") != "" ) {
                $myField = Session::newInstance()->_getForm("myField");
                parent::generic_textarea("myField", $myField);
            } else {
                parent::generic_textarea("myField", "");
            }
            return true;
        }

to oc-includes/osclass/classes/emailvariables.php

Code: [Select]
87: '{MY_FIELD}'        => __('My Field'),
themes/realestate/item.php

Code: [Select]
                            <fieldset>
                                <label for="yourName"><?php _e('Your namekk''realestate') ; ?>:</label> <?php ContactForm::your_name(); ?>
                                <label for="yourEmail"><?php _e('Your e-mail address''realestate') ; ?>:</label> <?php ContactForm::your_email(); ?>
                                <label for="phoneNumber"><?php _e('Phone number''realestate') ; ?> (<?php _e('optional''realestate'); ?>):</label> <?php ContactForm::your_phone_number(); ?>
                                 <label for="message"><?php _e('Message''realestate') ; ?>:</label> <?php ContactForm::your_message(); ?>
                                <label for="myField"><?php _e('myField''realestate') ; ?>:</label> <?php ContactForm::your_myField(); ?>
                        <input type="hidden" name="action" value="contact_post" />
                                <input type="hidden" name="page" value="item" />
                                <input type="hidden" name="id" value="<?php echo osc_item_id() ; ?>" />
                                <?php if( osc_recaptcha_public_key() ) { ?>
                                <script type="text/javascript">
                                    var RecaptchaOptions = {
                                        theme : 'custom',
                                        custom_theme_widget: 'recaptcha_widget'
                                    };
                                </script>
                                <style type="text/css"> div#recaptcha_widget, div#recaptcha_image > img { width:280px; } </style>
                                <div id="recaptcha_widget">
                                    <div id="recaptcha_image"><img /></div>
                                    <span class="recaptcha_only_if_image"><?php _e('Enter the words above','realestate'); ?>:</span>
                                    <input type="text" id="recaptcha_response_field" name="recaptcha_response_field" />
                                    <div><a href="javascript:Recaptcha.showhelp()"><?php _e('Help''realestate'); ?></a></div>
                                </div>
                                <?php ?>
                                <?php osc_show_recaptcha(); ?>
                                <a href="#" class="ui-button m-top-15 js-submit"><?php _e('Send''realestate') ; ?></a>
                            </fieldset>

to oc-includes/osclass/upgrade-func.php

187 :  $comm->query(sprintf("INSERT INTO %st_pages_description (fk_i_pages_id, fk_c_locale_code, s_title, s_text) VALUES (%d, 'en_US', '{WEB_TITLE} - Someone has a question for you', '<p>Hi {CONTACT_NAME}!</p>\n<p>{USER_NAME} ({USER_EMAIL}, {USER_PHONE}) left you a message:</p>\n<p>{COMMENT}</p>\n<p>{MY_FIELD}</p>\n<p>Regards,</p>\n<p>{WEB_TITLE}</p>')", DB_TABLE_PREFIX, $comm->insertedId()));
« Last Edit: May 29, 2014, 03:57:23 pm by keepdot »

keepdot

  • Newbie
  • *
  • Posts: 5
Re: Add extra fields for contact publisher
« Reply #3 on: June 01, 2014, 01:37:15 am »
I found the solution, do everything as in my previous post and edit oc-includes/osclass/itemaction.php

Code: [Select]
1037 :   $aItem['myField']   = Params::getParam('myField');

design

  • Hero Member
  • *****
  • Posts: 2619
  • Osclass 3.5 MAC/PC w/ Modern Browsers
Re: Add extra fields for contact publisher
« Reply #4 on: June 01, 2014, 01:38:37 am »
way to go!!