Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #5699

    How can i rearrange how the form displays on the contact page? I want to have it before the page content, not after…

    Also, how can I put text above the “message” field or in the message field… if it was in the message field is there a way to have the text disappear when someone clicks that field to type?

    Thanks

    #51438

    Anyone know how to do this?

    Thanks

    #51439

    Hey,

    excuse me for the late response.

    In your includes folder, your loop-page.php should contain this:

    //check if this is the contact form page, if so display the form
    if(avia_get_option('avia, email_page') == $post->ID) get_template_part( 'includes/contact-form' );

    cut it and put it in front of

    //display the actual post content
    the_content(__('Read more','avia_framework'));

    This should do.

    #51440

    This worked! Thanks! But how do I put text above the “message” field or in the message field… if it was in the message field is there a way to have the text disappear when someone clicks that field to type?

    Thanks!

    #51441

    Hey,

    to do this you can do the following:

    in your folder Framework>php>class-form-generator.php find :

    /**
    * text
    *
    * The text method creates input elements with type text, and prefills them with $_POST values if available.
    * The method also checks against various input validation cases
    * @param string $id holds the key of the element
    * @param array $element data array of the element that should be created
    */
    function text($id, $element)
    {
    $p_class = $required = $element_class = $value = "";

    if(!empty($element['check']))
    {
    $required = "*";
    $element_class = $element['check'];
    $p_class = $this->check_element($id, $element);
    }

    if(!empty($_POST[$id])) $value = urldecode($_POST[$id]);

    $this->elements_html .= "<p class='".$p_class."'>";
    $this->elements_html .= ' <input name="'.$id.'" class="text_input '.$element_class.'" type="text" id="'.$id.'" value="'.$value.'"/><label for="'.$id.'">'.$element['label'].$required.'</label>';
    $this->elements_html .= "</p>";
    }

    /**
    * textarea
    *
    * The textarea method creates textarea elements, and prefills them with $_POST values if available.
    * The method also checks against various input validation cases
    * @param string $id holds the key of the element
    * @param array $element data array of the element that should be created
    */
    function textarea($id, $element)
    {
    $p_class = $required = $element_class = $value = "";

    if(!empty($element['check']))
    {
    $element_class = $element['check'];
    $p_class = $this->check_element($id, $element);
    }

    if(!empty($_POST[$id])) $value = urldecode($_POST[$id]);

    $this->elements_html .= "<p class='".$p_class."'>";
    $this->elements_html .= ' <textarea name="'.$id.'" class="text_area '.$element_class.'" cols="40" rows="7" id="'.$id.'" >'.$value.'</textarea>';
    $this->elements_html .= "</p>";
    }

    and replace it by :

    /**
    * text
    *
    * The text method creates input elements with type text, and prefills them with $_POST values if available.
    * The method also checks against various input validation cases
    * @param string $id holds the key of the element
    * @param array $element data array of the element that should be created
    */
    function text($id, $element)
    {
    $p_class = $required = $element_class = $value = "";

    if(!empty($element['check']))
    {
    $required = "*";
    $element_class = $element['check'];

    $p_class = $this->check_element($id, $element);
    }

    if(!empty($_POST[$id])) $value = urldecode($_POST[$id]);
    $value = $element['value'];
    $this->elements_html .= "<p class='".$p_class."'>";
    $this->elements_html .= ' <input name="'.$id.'" class="text_input '.$element_class.'" type="text" id="'.$id.'" value="'.$value.'"/>';
    $this->elements_html .= "</p>";
    }

    /**
    * textarea
    *
    * The textarea method creates textarea elements, and prefills them with $_POST values if available.
    * The method also checks against various input validation cases
    * @param string $id holds the key of the element
    * @param array $element data array of the element that should be created
    */
    function textarea($id, $element)
    {
    $p_class = $required = $element_class = $value = "";
    $value = $element['value'];

    if(!empty($element['check']))
    {
    $element_class = $element['check'];
    $p_class = $this->check_element($id, $element);
    }

    if(!empty($_POST[$id])) $value = urldecode($_POST[$id]);

    $this->elements_html .= "<p class='".$p_class."'>";
    $this->elements_html .= ' <textarea name="'.$id.'" class="text_area '.$element_class.'" cols="40" rows="7" id="'.$id.'" >'.$value.'</textarea>';
    $this->elements_html .= "</p>";
    }

    And in your contact-form.php, found in your includes folder, change this:

    $elements = array(

    'yourname' => array('type'=>'text', 'label'=>__('Name','avia_framework'), 'check'=>'is_empty'), //user name
    'email' => array('type'=>'text', 'label'=>__('E-Mail','avia_framework'), 'check'=>'is_email'), //user email
    'website' => array('type'=>'text', 'label'=>__('Website','avia_framework'), 'check'=>''), //user website
    'subject' => array('type'=>'text', 'label'=>__('Subject','avia_framework'), 'check'=>'is_empty'), //subject
    'message' => array('type'=>'textarea','label'=>__('Message','avia_framework'), 'check'=>'is_empty'), //message
    'myemail' => array('type'=>'hidden', 'label'=>'', 'check'=>'', 'value'=> avia_get_option('avia, email') ), //email adress the form should be sent to
    'myblogname'=> array('type'=>'hidden', 'label'=>'', 'check'=>'', 'value'=> get_option('blogname') ), //name of the website, gets added to the subject line
    'username' => array('type'=>'decoy', 'label'=>'', 'check'=>'must_empty'), //decoy input field for bots, input field gets hidden, if bot enters value form wont be submitted

    );

    to this:

    $elements = array(

    'yourname' => array('type'=>'text', 'value'=>'Name*', 'label'=>__('Name','avia_framework'), 'check'=>'is_empty'), //user name
    'email' => array('type'=>'text', 'value'=>'E-Mail*', 'label'=>__('E-Mail','avia_framework'), 'check'=>'is_email'), //user email
    'website' => array('type'=>'text', 'value'=>'Website', 'label'=>__('Website','avia_framework'), 'check'=>''), //user website
    'subject' => array('type'=>'text', 'value'=>'Subject*', 'label'=>__('Subject','avia_framework'), 'check'=>'is_empty'), //subject
    'message' => array('type'=>'textarea','value'=>'Your Message ..', 'label'=>__('Message','avia_framework'), 'check'=>'is_empty'), //message
    'myemail' => array('type'=>'hidden', 'label'=>'', 'check'=>'', 'value'=> avia_get_option('avia, email') ), //email adress the form should be sent to
    'myblogname'=> array('type'=>'hidden', 'label'=>'', 'check'=>'', 'value'=> get_option('blogname') ), //name of the website, gets added to the subject line
    'username' => array('type'=>'decoy', 'label'=>'', 'check'=>'must_empty'), //decoy input field for bots, input field gets hidden, if bot enters value form wont be submitted

    );

    Excuse me for the delay. I hope this works for you. – Does for me.

Viewing 5 posts - 1 through 5 (of 5 total)

The topic ‘How to have contact form above content on contact page?’ is closed to new replies.