Tutorial: contact form using fancybox

Discussion in 'Tutorials' started by freeze2, May 9, 2013.

  1. freeze2 Super Moderator

    I've been working on a new site for one of our customers and thought I would share how to spice up your contact form using a couple of easy modifications and some css.

    This is basically a continuation of my Switch Image Gallery to "Fancybox" post:

    http://www.68classifieds.com/forums/threads/tutorial-switch-image-gallery-to-fancybox.11823/

    Assuming you have Fancybox installed, you will need to do the following:

    Step 1.

    In your template folder using layout.tpl, create a new template called contact.tpl. This template should be stripped of all website header, nav, footer etc. Basically, you would want to create a very simple page to load with Fancybox. All I left between the <body> tags was:

    Code:
    <div id="content">
    {include file=$body}
    </div>
    Step 2.

    Open contact.php and do the following:

    At approx Line 118 and 145

    Replace

    Code:
    $class_tpl->display('layout.tpl');
    With

    Code:
    $class_tpl->display('contact.tpl');
    Step 3.

    Remove the following from the bottom of your viewlisting.tpl

    Code:
    {dynamic}
    {if $pmon=="Y" && $smarty.session.uid > 0}
     
    {elseif $allowcontact=="Y" && $display=="Y"}
        {include file=contact/contactowner.tpl}
    {/if}
    {/dynamic}
    Create a link on the viewlisting.tpl like this:

    Code:
    <div id="email">
    <a class="iframe" href="http://www.mywebsite.com/path-to-68c-install/contact.php?ownerid={$owner}&listingid={$lid}">Text you want on the link</a>
    <script>
    $(document).ready(function(){
    $(".iframe").fancybox({
    'width' : 540,
    'height' : 620,
    'overlayOpacity' : '0.7',
    'overlayColor' : '#000',
    'type' : 'iframe'
    });
    });
    </script>
    </div>
    Style the link anyway you like...mine looks like this:

    [IMG]


    With a little CSS added, you can have your contact form that opens up with Fancybox and looks like this on your viewlisting page.

    [IMG]
    Mike-N-Tosh likes this.

Share This Page