Question

How would I go about creating a simple popup from a 'view.phtml' on a product page that would popup 'form.phtml' from template/contacts.

I am trying to create a free quote button on a product page, so I would like the the form to have the basic contact form, but also have the submit email the address link that the user was left off on, or the product image.

Is this easily done? or is there a paid solution somewhere?

Thanks

Was it helpful?

Solution

You'll need a custom module but it does not take much work if you know some basics of module development:

  1. create a controller action that does nothing more than

    $this->loadLayout();
    $this->renderLayout();
    
  2. Create a layout handle for this controller and include the predefined page_empty layout handle (this removes header, footer and sidebars, using page/empty.html as root template). Also add the contact form block via layout:

    <layout>
        <your_controller_action>
            <update handle="page_empty"/>
            <reference name="content">
                <block type="core/template" name="contactForm" template="contacts/form.phtml"/>
            </reference>
        </your_controller_action>
    </layout>
    
  3. if you want to prefill the contact form text area, you'll have to use an adjusted contacts/form.phtml which takes a parameter for the default value of the text area. Copy contacts/form.phtml to sth. like mycontact/form.phtml (change the template path in the layout XML accordingly), and change this line

    <textarea name="comment" id="comment" title="<?php echo Mage::helper('contacts')->__('Comment') ?>" class="required-entry input-text" cols="5" rows="3"></textarea>
    

    to

    <textarea name="comment" id="comment" title="<?php echo Mage::helper('contacts')->__('Comment') ?>" class="required-entry input-text" cols="5" rows="3"><?php echo $this->escapeHtml($this->getMessage()) ?></textarea>
    

    Then add this line to your controller action:

    $this->getLayout()->getBlock('contactForm')->setMessage(
        $this->getRequest()->getParam('message'));
    
  4. Finally, create a link to open the popup in your product/view.phtml:

    <?php
    $popupMessage = "This message will be prefilled in the popup contact form.\n";
    $popupMessage.= "You can add the product URL or anything else here:\n";
    $popupMessage.= $this->getProduct()->getUrl();
    ?>
    <a href="javascript:popWin('<?php echo $this->quoteEscape($this->getUrl('your/controller/action', array('message' => $popupMessage)))); ?>', 'contact')">Popup</a>
    

OTHER TIPS

You need to create pop yourself .I will give you how to call contacts us form at product view page by below code

<?php   $this->getLayout()->getCreateBlock('catalog/product_view')
->setFormAction( Mage::getUrl('cotacts/index/post') )->setTemplate('contacts/productform.phtml')->toHtml(); ?>

Here I create a template file productform.phtml which is replicate of default contacts>form.phtml file.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top