VirtueMart Forum

VirtueMart Dev/Coding Central: VM1 (old version) => Development Projects, Modifications, Hacks & Tweaks. VM1.1 => Topic started by: rb on October 22, 2009, 18:36:29 pm

Title: Ask question form included on flypage AJAX
Post by: rb on October 22, 2009, 18:36:29 pm
I believe I have produced a solution to the request for a an "inline" version of the "Ask a question about this product".  It uses Ajax, so the users stays on the flypage  even while requesting and sending a question.  Check it out and let me know if it works for you. 

To install, download the Zip file, unZip it, read the readme file and follow the instructions.


[attachment cleanup by admin]
Title: Ask question form included on flypage AJAX
Post by: PRO on October 22, 2009, 18:53:36 pm
confirmed. WORKS

ONLY thing, what if the user clicks the link, and decides not to send the form, How can they close it?

EDIT , sorry, Cancel button works
Title: Ask question form included on flypage AJAX
Post by: jjj2 on October 23, 2009, 17:25:13 pm
I believe I have produced a solution to the request for a an "inline" version of the "Ask a question about this product".  It uses Ajax, so the users stays on the flypage  even while requesting and sending a question.  Check it out and let me know if it works for you. 

To install, download the Zip file, unZip it, read the readme file and follow the instructions.


Hi :) Thanks for the solution..I have a strong feeling that it's gonna work..
Just need some tuning coz I'm putting that into a Tab using Magic Tabs.
I got strange result as the "Ask a Question.." link appears outside the tab just like the picture attached.

My flypage code :
Code: [Select]
<style type="text/css">
<!--

#headerButtons {
margin-bottom: 10px;
display: block;
height: auto;
overflow: auto;
}
#img_desc_container {
min-height:250px;
    height:auto !important;
    height:250px;

}
#productImage {
float: left;
padding-right: 20px;
width:40%;
text-align:center;
/*overflow: auto;*/
}
#productDescription
{
float:left;
/*padding: 10px;*/
width:50%;
}
#productPrice
{
padding: 10px 0px;
}
#productReviews
{
padding: 5px 0px;
margin: 10px 0px 10px;
}
#productAvailability
{
padding: 10px 0px 10px;
overflow: auto;
}
#addCart {
overflow: auto;
}
#askQuestion
{
padding: 10px 0px;
}
#additionalImages {
margin-top:30px;
/*border-top: thin solid #DDDDDD;
border-bottom: thin solid #DDDDDD;
overflow: auto;*/
}
#add_img_bdr img{
padding: 1px;
margin: 10px;
border:thin solid #CCCCCC;
}


-->
</style>


<?php if( !defined'_VALID_MOS' ) && !defined'_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' ); ?>


<div id="headerButtons"><?php echo $buttons_header // The PDF, Email and Print buttons ?>
<?php
if( $this->get_cfg'showPathway' )) {
echo "<div class=\"pathway\">$navigation_pathway</div>";
}
if( 
$this->get_cfg'product_navigation')) {
if( !empty( $previous_product )) {
echo '<a class="previous_page" href="'.$previous_product_url.'">'.shopMakeHtmlSafe($previous_product['product_name']).'</a>';
}
if( !empty( $next_product )) {
echo '<a class="next_page" href="'.$next_product_url.'">'.shopMakeHtmlSafe($next_product['product_name']).'</a>';
}
}
?>
</div>


<div id="productTitle"><h1><?php echo $product_name ?></h1>
<?php echo $edit_link ?></div>
<div id="img_desc_container">
<div id="productImage"><?php echo $product_image ?>
<!--<img src="components/com_virtuemart/shop_image/product/<?php echo $product_full_image ?>" style="width: 250px; border:none;" alt="<?php echo $product_name ?>" />-->
</div>
<div id="productDescription">
<?php
$template 
'{magictabs}';
$template .= $VM_LANG->_('PHPSHOP_PRODUCT_DESC_TITLE');
$template .= '::';
$template .= '<div>';
$template .= $product_description;
$template .= '</div>';
$template .= '||||';
$template .= 'Ask Question';
$template .= '::';
//$template .= '<div>';
$template .= include ('flypage-ask-inline.tpl.php'); //include ('components/com_virtuemart/themes/default/templates/pages/shop.ask.tpl.php')
//$template .= '</div>';
$template .= '{/magictabs}';
?>


<?php echo JHTML::_('content.prepare'$template); ?> </div>

</div>

<div id="productPrice"><?php echo $product_price_lbl ?> <?php echo $product_price ?></div>
<div id="productPackaging"><?php echo $product_packaging ?></div>

<div id="additionalImages"><br/>
<div id="add_img_bdr"> <?php echo $this->vmlistAdditionalImages$product_id$images ?></div>
  </div>


<?php if( $this->get_cfg('showManufacturerLink')) { ?>
<div id="manufacturerLink"><?php echo $manufacturer_link ?></div>
<?php ?>
<?php if( $this->get_cfg('showAvailability')) { ?>
<div id="productAvailability"><?php echo $product_availability ?></div>
<?php ?>


<div id="addCart"><?php echo $addtocart ?></div>
<div id="productType"><?php echo $product_type ?></div>

<div id="reviewForum"><?php echo $product_reviewform ?></div>
<div id="relatedProducts"><?php echo $related_products ?></div>

<?php if( $this->get_cfg('showVendorLink')) { ?>
<div id="vendorLink"><?php echo $vendor_link ?></div>
<?php ?>

<div id="recentProducts">
  <?php if( !empty( $recent_products )) { ?>
  <span class="vmRecent"><?php echo $recent_products?></span></div>
<div id="categoryNavigation">
  <?php 
}
if( !empty( $navigation_childlist )) { ?>

  <?php echo $VM_LANG->_('PHPSHOP_MORE_CATEGORIES'?><br />
  <?php echo $navigation_childlist ?><br style="clear:both"/>
  <?php 
?>

</div>

Any idea about this ? Thanks in advance.

[attachment cleanup by admin]
Title: Re: Ask question form included on flypage AJAX
Post by: PRO on October 23, 2009, 17:38:14 pm
If you are going to put it in a tab, you are not going to use the original ONclick function

It should be pre-loaded in that tab
Title: Re: Ask question form included on flypage AJAX
Post by: jjj2 on October 23, 2009, 18:21:47 pm
If you are going to put it in a tab, you are not going to use the original ONclick function

It should be pre-loaded in that tab

Hi..Thanks for pointing that out.

Well it's actually fina for me to have the onclick link...

It's just I couldn't figure out why would the link appears outside the tab like shown in the attached image ?
Title: Re: Ask question form included on flypage AJAX
Post by: aravot on October 23, 2009, 22:09:18 pm
You have a 'undefined variable' notice.

Quote
Notice:  Undefined variable: subject in /home/site.com/components/com_virtuemart/themes/default/templates/product_details/flypage-ask-inline.tpl.php on line 92
Title: Re: Ask question form included on flypage AJAX
Post by: rb on October 25, 2009, 14:49:41 pm
BT.Pro and aravot: the line generating the Notice in flypage-ask-inline.tpl.php (line 92) is:
Code: [Select]
<textarea rows="10" cols="60" name="text" id="contact_text" class="inputbox"><?php echo $subject ?></textarea><br /><br />The variable $subject isn't needed for this hack, so the line can be changed to:
Code: [Select]
<textarea rows="10" cols="60" name="text" id="contact_text" class="inputbox"></textarea><br /><br />and the Notice should go away.
Title: Re: Ask question form included on flypage AJAX
Post by: jjj2 on October 26, 2009, 08:35:03 am
Hi rb,

Can u help me on the code ? I still can't figure out why the "Ask a question on this product" appearing outside the tab ..

Just like what I'm showing on the attachment above.

Thanks again.
Title: Re: Ask question form included on flypage AJAX
Post by: rb on October 26, 2009, 14:55:32 pm
Without having a link to view your site, I'm not 100% sure what is causing your issue, but one possibility is that the file flypage-ask-inline.tpl.php hasn't been modified as mentioned in its readme file.  That is, when you use this add-on in the Description area, you must handle the HTML TR and TD tags properly per your layout.
Title: Re: Ask question form included on flypage AJAX
Post by: Intel386 on October 27, 2009, 02:29:33 am
Thanks aboaut solution !But how to intergrated with plug_in rokbox ?
Title: Re: Ask question form included on flypage AJAX
Post by: rb on October 28, 2009, 14:10:00 pm
Hi Intel386,
As far as my limited understanding of the Rokbox plugin goes, it seems like this add-on would not be appropriate for it.  This add-on shows the "ask a question" form WITHIN the existing page, while Rokbox shows content in a lightbox ABOVE the existing page.  One advantage to having the form within the page, is that the user can view the entire flypage contents while composing their email (including copying and pasting of any text).  If you put the form in a lightbox, the user cannot view the entire flypage and cannot copy/paste.  But that's just my opinion - perhaps I'm not understanding what it is you're trying to do.
Title: Re: Ask question form included on flypage AJAX
Post by: jjj2 on October 28, 2009, 15:16:51 pm
Without having a link to view your site, I'm not 100% sure what is causing your issue, but one possibility is that the file flypage-ask-inline.tpl.php hasn't been modified as mentioned in its readme file.  That is, when you use this add-on in the Description area, you must handle the HTML TR and TD tags properly per your layout.

Hi rb,

You can take a look at my site here> http://www.ecompsolts.com/demo/OAM/BR/index.php?page=shop.product_details&flypage=flypage.tpl&product_id=2&category_id=19&option=com_virtuemart&Itemid=122

Thanks.
Title: Re: Ask question form included on flypage AJAX
Post by: rb on October 28, 2009, 15:53:58 pm
jjj2, when I view your page source, I see that the code that displays the link "Ask a question about this product" is clearly outside of your magic tabs, so I would guess that you put it there either by modifying the template, or by adding the code in your product description prior to your magic tabs definitions.
Title: Re: Ask question form included on flypage AJAX
Post by: jjj2 on October 28, 2009, 16:40:48 pm
Hi rb,

Thanks for your prompt reply :)

I make sure I put in the code in the magic tab, it is working fine if I were to put some dummy text. The dummy text wil apeear perfectly under the "Ask Question" tab.
But if I include in the flypage-ask-inline.tpl.php, it's showing outside the tab. It's strange ...

Here is my code in flypage >

Code: [Select]
<style type="text/css">
<!--

#headerButtons {
margin-bottom: 10px;
display: block;
height: auto;
overflow: auto;
}
#img_desc_container {
min-height:250px;
    height:auto !important;
    height:250px;

}
#productImage {
float: left;
padding-right: 20px;
width:40%;
text-align:center;
/*overflow: auto;*/
}
#productDescription
{
float:left;
/*padding: 10px;*/
width:50%;
}
#productPrice
{
padding: 10px 0px;
}
#productReviews
{
padding: 5px 0px;
margin: 10px 0px 10px;
}
#productAvailability
{
padding: 10px 0px 10px;
overflow: auto;
}
#addCart {
overflow: auto;
}
#askQuestion
{
padding: 10px 0px;
}
#additionalImages {
margin-top:30px;
/*border-top: thin solid #DDDDDD;
border-bottom: thin solid #DDDDDD;
overflow: auto;*/
}
#add_img_bdr img{
padding: 1px;
margin: 10px;
border:thin solid #CCCCCC;
}


-->
</style>


<?php if( !defined'_VALID_MOS' ) && !defined'_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' ); ?>


<div id="headerButtons"><?php echo $buttons_header // The PDF, Email and Print buttons ?>
<?php
if( $this->get_cfg'showPathway' )) {
echo "<div class=\"pathway\">$navigation_pathway</div>";
}
if( 
$this->get_cfg'product_navigation')) {
if( !empty( $previous_product )) {
echo '<a class="previous_page" href="'.$previous_product_url.'">'.shopMakeHtmlSafe($previous_product['product_name']).'</a>';
}
if( !empty( $next_product )) {
echo '<a class="next_page" href="'.$next_product_url.'">'.shopMakeHtmlSafe($next_product['product_name']).'</a>';
}
}
?>
</div>


<div id="productTitle"><h1><?php echo $product_name ?></h1>
<?php echo $edit_link ?></div>
<div id="img_desc_container">
<div id="productImage"><?php echo $product_image ?>
<!--<img src="components/com_virtuemart/shop_image/product/<?php echo $product_full_image ?>" style="width: 250px; border:none;" alt="<?php echo $product_name ?>" />-->
</div>
<div id="productDescription">
<?php
$template 
'{magictabs}';
$template .= $VM_LANG->_('PHPSHOP_PRODUCT_DESC_TITLE');
$template .= '::';
$template .= '<div>';
$template .= $product_description;
$template .= '</div>';
$template .= '||||';
$template .= 'Ask Question';
$template .= '::';
//$template .= '<div>';
$template .= include ('flypage-ask-inline.tpl.php'); //include ('components/com_virtuemart/themes/default/templates/pages/shop.ask.tpl.php')
//$template .= '</div>';
$template .= '{/magictabs}';
?>


<?php echo JHTML::_('content.prepare'$template); ?> </div>

</div>

<div id="productPrice"><?php echo $product_price_lbl ?> <?php echo $product_price ?></div>
<div id="productPackaging"><?php echo $product_packaging ?></div>

<div id="additionalImages"><br/>
<div id="add_img_bdr"> <?php echo $this->vmlistAdditionalImages$product_id$images ?></div>
  </div>


<?php if( $this->get_cfg('showManufacturerLink')) { ?>
<div id="manufacturerLink"><?php echo $manufacturer_link ?></div>
<?php ?>
<?php if( $this->get_cfg('showAvailability')) { ?>
<div id="productAvailability"><?php echo $product_availability ?></div>
<?php ?>


<div id="addCart"><?php echo $addtocart ?></div>
<div id="productType"><?php echo $product_type ?></div>

<div id="reviewForum"><?php echo $product_reviewform ?></div>
<div id="relatedProducts"><?php echo $related_products ?></div>

<?php if( $this->get_cfg('showVendorLink')) { ?>
<div id="vendorLink"><?php echo $vendor_link ?></div>
<?php ?>

<div id="recentProducts">
  <?php if( !empty( $recent_products )) { ?>
  <span class="vmRecent"><?php echo $recent_products?></span></div>
<div id="categoryNavigation">
  <?php 
}
if( !empty( $navigation_childlist )) { ?>

  <?php echo $VM_LANG->_('PHPSHOP_MORE_CATEGORIES'?><br />
  <?php echo $navigation_childlist ?><br style="clear:both"/>
  <?php 
?>

</div>
Title: Re: Ask question form included on flypage AJAX
Post by: rb on October 28, 2009, 17:45:12 pm
jjj2,
I believe your problem is on line 104 of your template:
Code: [Select]
$template .= include ('flypage-ask-inline.tpl.php');
PHP doesn't append the CONTENTS of the INCLUDEd file to your variable $template.  Instead, the INCLUDEd file is brought in at that point in time which is prior to the magic tabs being brought in via the content.prepare statement.  The RESULT of the INCLUDE is successful, so the value of "1" is appended to $template.  You can see the "1" in your magic tab.
Title: Re: Ask question form included on flypage AJAX
Post by: jjj2 on October 28, 2009, 18:49:49 pm
jjj2,
I believe your problem is on line 104 of your template:
Code: [Select]
$template .= include ('flypage-ask-inline.tpl.php');
PHP doesn't append the CONTENTS of the INCLUDEd file to your variable $template.  Instead, the INCLUDEd file is brought in at that point in time which is prior to the magic tabs being brought in via the content.prepare statement.  The RESULT of the INCLUDE is successful, so the value of "1" is appended to $template.  You can see the "1" in your magic tab.

Hi rb...

You pointed out a very useful point..

I wonder how could I actually load the flypage-ask-inline.tpl.php into the Magic Tabs...

Can anyone help on this ?

Thanks in advance.
Title: Re: Ask question form included on flypage AJAX
Post by: rb on October 28, 2009, 19:16:24 pm
This is just a PHP question. Copy from flypage-ask-inline.tpl.php and paste into your flypage, assigning to your $template variable using PHP's heredoc or nowdoc syntax.  Read the PHP manual for usage.
Title: Re: Ask question form included on flypage AJAX
Post by: jjj2 on October 30, 2009, 06:02:09 am
This is just a PHP question. Copy from flypage-ask-inline.tpl.php and paste into your flypage, assigning to your $template variable using PHP's heredoc or nowdoc syntax.  Read the PHP manual for usage.

Hi rb,

Thanks for that :) I read through the PHP manual for both HereDoc & NowDoc syntax..I found it's hard for me to implement it in my case :)

Anyway, I use another method of including the PHP into a variable, just like the followings :

My FlyPage :
Code: [Select]
<style type="text/css">
<!--

#headerButtons {
margin-bottom: 10px;
display: block;
height: auto;
overflow: auto;
}
#img_desc_container {
min-height:250px;
    height:auto !important;
    height:250px;

}
#productImage {
float: left;
padding-right: 20px;
width:40%;
text-align:center;
/*overflow: auto;*/
}
#productDescription
{
float:left;
/*padding: 10px;*/
width:50%;
}
#productPrice
{
padding: 10px 0px;
}
#productReviews
{
padding: 5px 0px;
margin: 10px 0px 10px;
}
#productAvailability
{
padding: 10px 0px 10px;
overflow: auto;
}
#addCart {
overflow: auto;
}
#askQuestion
{
padding: 10px 0px;
}
#additionalImages {
margin-top:30px;
/*border-top: thin solid #DDDDDD;
border-bottom: thin solid #DDDDDD;
overflow: auto;*/
}
#add_img_bdr img{
padding: 1px;
margin: 10px;
border:thin solid #CCCCCC;
}


-->
</style>


<?php if( !defined'_VALID_MOS' ) && !defined'_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' ); ?>


<div id="headerButtons"><?php echo $buttons_header // The PDF, Email and Print buttons ?>
<?php
if( $this->get_cfg'showPathway' )) {
echo "<div class=\"pathway\">$navigation_pathway</div>";
}
if( 
$this->get_cfg'product_navigation')) {
if( !empty( $previous_product )) {
echo '<a class="previous_page" href="'.$previous_product_url.'">'.shopMakeHtmlSafe($previous_product['product_name']).'</a>';
}
if( !empty( $next_product )) {
echo '<a class="next_page" href="'.$next_product_url.'">'.shopMakeHtmlSafe($next_product['product_name']).'</a>';
}
}
?>
</div>


<div id="productTitle"><h1><?php echo $product_name ?></h1>
<?php echo $edit_link ?></div>
<div id="img_desc_container">
<div id="productImage"><?php echo $product_image ?>
<!--<img src="components/com_virtuemart/shop_image/product/<?php echo $product_full_image ?>" style="width: 250px; border:none;" alt="<?php echo $product_name ?>" />-->
</div>

<?php
ob_start
(); # start buffer
include_once( 'flypage-ask-inline.tpl.php' );
# we pass the output to a variable
$ask_question ob_get_contents();
ob_end_clean(); # end buffer
?>


<div id="productDescription">
<?php
$template 
'{magictabs}';
$template .= $VM_LANG->_('PHPSHOP_PRODUCT_DESC_TITLE');
$template .= '::';
$template .= '<div>';
$template .= $product_description;
$template .= '</div>';
$template .= '||||';
$template .= 'Ask Question';
$template .= '::';
$template .= '<div>';
$template .= $ask_question;
$template .= '</div>';
$template .= '{/magictabs}';
?>


<?php echo JHTML::_('content.prepare'$template); ?> </div>

</div>

<div id="productPrice"><?php echo $product_price_lbl ?> <?php echo $product_price ?></div>
<div id="productPackaging"><?php echo $product_packaging ?></div>

<div id="additionalImages"><br/>
<div id="add_img_bdr"> <?php echo $this->vmlistAdditionalImages$product_id$images ?></div>
  </div>


<?php if( $this->get_cfg('showManufacturerLink')) { ?>
<div id="manufacturerLink"><?php echo $manufacturer_link ?></div>
<?php ?>
<?php if( $this->get_cfg('showAvailability')) { ?>
<div id="productAvailability"><?php echo $product_availability ?></div>
<?php ?>


<div id="addCart"><?php echo $addtocart ?></div>
<div id="productType"><?php echo $product_type ?></div>

<div id="reviewForum"><?php echo $product_reviewform ?></div>
<div id="relatedProducts"><?php echo $related_products ?></div>

<?php if( $this->get_cfg('showVendorLink')) { ?>
<div id="vendorLink"><?php echo $vendor_link ?></div>
<?php ?>

<div id="recentProducts">
  <?php if( !empty( $recent_products )) { ?>
  <span class="vmRecent"><?php echo $recent_products?></span></div>
<div id="categoryNavigation">
  <?php 
}
if( !empty( $navigation_childlist )) { ?>

  <?php echo $VM_LANG->_('PHPSHOP_MORE_CATEGORIES'?><br />
  <?php echo $navigation_childlist ?><br style="clear:both"/>
  <?php 
?>

</div>

My flypage-ask-inline.tpl.php :>
Code: [Select]
<?php if( !defined'_VALID_MOS' ) && !defined'_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' ); 
/*
* flypage-ask-inline.tpl.php version 1.0b
*  Copyright (C) 2009 Rick Baer - All rights reserved.
*/
?>


<style type="text/css">
div.ask_inline {
/*display:none;*/
border: solid 1px #ccc;
margin-top: 5px;
padding: 5px;
width:300px;
}
</style>



<script type="text/javascript"><!--
// Ajax handler for sending "Ask a question about this product" email

function handleAskProdQuest( formId, parameters ) {
formEmail = document.getElementById( formId );

var respMsg = parameters;

var callback = function(responseText) {

// close an existing mooPrompt box first, before attempting to create a new one (thanks wellsie!)
if (document.boxB) {
document.boxB.close();
clearTimeout(timeoutID);
}

// Prepare response message
if (responseText.indexOf('>Success<') > 0) {
responseText = respMsg;
document.getElementById('ask_inline').style.display='none';
} else {
responseText = 'Your product question was not emailed due to an internal error';
};

document.boxB = new MooPrompt(notice_lbl, responseText, {
buttons: 1,
width:400,
height:150,
overlay: false,
button1: ok_lbl
});

setTimeout( 'document.boxB.close()', 5000 );
}

var opt = {
    // Use POST
    method: 'post',
    // Send this lovely data
    data: $(formId),
    // Handle successful response
    onComplete: callback,
   
    evalScripts: true
}

new Ajax(formEmail.action, opt).request();
}

--></script>




<!--<a class="button" href="" onclick="document.getElementById('ask_inline').style.display='block';return false;"><?php echo $ask_seller_text?></a>-->



   
  <div id="ask_inline" class="ask_inline" >

<form action="<?php echo $mm_action_url ?>index.php" method="post" name="emailForm" id="emailForm" onsubmit="validateEnquiryForm(this.id); return false;">
<label for="contact_name"><?php echo $VM_LANG->_('NAME_PROMPT'?></label><br />
<input type="text" name="name" id="contact_name" size="30" class="inputbox" value="<?php echo $my->name?>"><br />

<label for="contact_mail"><?php echo $VM_LANG->_('EMAIL_PROMPT'?></label><br />
<input type="text" id="contact_mail" name="email" size="30" label="Your email" class="inputbox" value="<?php echo $my->email?>"><br />

<label for="contact_text"><?php echo $VM_LANG->_('MESSAGE_PROMPT'?></label><br />
<textarea rows="6" cols="40" name="text" id="contact_text" class="inputbox"><?php echo $subject ?></textarea><br />

<input type="submit" name="send" value="<?php echo $VM_LANG->_('SEND_BUTTON'?>" class="button" />
&nbsp; &nbsp; 
<input type="button" name="cancel" class="button" value="<?php echo $VM_LANG->_('CMN_CANCEL'); ?>"  onclick="document.getElementById('ask_inline').style.display='none'; return false;">


<input type="hidden" name="product_id" value="<?php echo $product_id  ?>" />
<input type="hidden" name="product_sku" value="<?php echo $product_sku  ?>" />
<input type="hidden" name="set" value="1" />
<input type="hidden" name="func" value="productAsk" />
<input type="hidden" name="page" value="shop.ask" />
<input type="hidden" name="option" value="com_virtuemart" />
<input type="hidden" name="flypage" value="<?php echo $flypage ?>" />
<input type="hidden" name="Itemid" value="<?php echo $Itemid ?>" />

<input type="hidden" name="<?php echo $validate ?>" value="1" />
</form>
<script type="text/javascript"><!--


function validateEnquiryForm(form_id) {
if ( ( document.emailForm.text.value == "" ) || ( document.emailForm.email.value.search("@") == -1 ) || ( document.emailForm.email.value.search("[.*]" ) == -1 ) ) {
alert( "<?php echo $VM_LANG->_('CONTACT_FORM_NC',false); ?>" );
} else if ( ( document.emailForm.email.value.search(";") != -1 ) || ( document.emailForm.email.value.search(",") != -1 ) || ( document.emailForm.email.value.search(" ") != -1 ) ) {
alert( "You cannot enter more than one email address" );
} else {
document.emailForm.action = "<?php echo sefRelToAbs("index.php"); ?>"
handleAskProdQuest(form_id,"<?php echo $VM_LANG->_('THANK_MESSAGE'?>"); // Ajax request
}
}
--></script>

  </div>

It's working perfectly now.

P/S : Just a little bit of enhancement, can I have the Ask Question form loaded back as empty form after the message is sent ? This is because I found that after the message is sent, and after the Thank You message, the existing space for the Ask Question form is blank.


Thanks rb, & thanks for others who contribute ideas & solutions :)
Title: Re: Ask question form included on flypage AJAX
Post by: rb on October 30, 2009, 13:59:09 pm
jjj2,
After being sent, the inline form is intentionally hidden by this JS statement:
Code: [Select]
document.getElementById('ask_inline').style.display='none';If you wish to have the filled-in form displayed, remove that statement.  To clear the filled-in fields, decide which ones you wish cleared, then in place of the removed line above, add JS statements to set those Input field values to empty strings.
Title: Re: Ask question form included on flypage AJAX
Post by: drevokocur on November 16, 2009, 13:00:49 pm
I was able to integrate nicely the magic tabs included the ask seller inline to my template, but the last thnig that I need is the "more images" or "additional images" , If I insert the $more_images, I get only a link to these images. I need to display them directly on the site. Before the tabbed layout worked for me this:
Quote
<?php echo $this->vmlistAdditionalImages( $product_id, $images ) ?>
But now I don`t know how to integrate it in the tab. Any idea?? :)
Title: Re: Ask question form included on flypage AJAX
Post by: rb on November 16, 2009, 16:11:58 pm
drevokocur, your question is actually a MagicTabs Additional Images question, not really directly related to this topic.  You'd probably get a faster response by starting a new topic.

Anyhow, if you are building your MagicTabs content within your Flypage, this might work for you (if not, try posting it as a new topic):
Code: [Select]
$template = '{magictabs}';

$template .= $VM_LANG->_('PHPSHOP_PRODUCT_DESC_TITLE');
$template .= '::';
$template .= $product_description;
$template .= '||||';

$template .= $VM_LANG->_('PHPSHOP_MORE_IMAGES');
$template .= '::';
$template .= $this->vmlistAdditionalImages( $product_id, $images );

$template .= '{/magictabs}';

echo JHTML::_('content.prepare', $template);
Title: Re: Ask question form included on flypage AJAX
Post by: drevokocur on November 16, 2009, 17:00:51 pm
Thanks rb! It has worked! :) Sorry for the bad posting.

I`ve been successful with integration of Magic Tabs with inline ask seller (thanks to this topic) and also with JV Tabs in virtuemart flypage (J1.5,V1.1.2) and it looks great. So if someone has a problem with this, I can help. ;)
Title: Re: Ask question form included on flypage AJAX
Post by: akeem76 on December 03, 2009, 09:41:54 am
may i view your site? :)
Title: Re: Ask question form included on flypage AJAX
Post by: Ventsi Genchev on December 06, 2009, 16:40:24 pm
When I try to send a question, I get the following error:

MooPrompt is not defined
Title: Re: Ask question form included on flypage AJAX
Post by: rb on December 06, 2009, 16:55:59 pm
Be sure that "Use Ajax to add, update or delete products from the cart?" is set to "Yes" in your Theme Settings:
Admin->Configuration->Site tab->Layout box->click "Configuration"
Title: Re: Ask question form included on flypage AJAX
Post by: Ventsi Genchev on December 06, 2009, 17:05:06 pm
Yes, it is set to "Yes".
I use mynxx template from Rocket.
Title: Re: Ask question form included on flypage AJAX
Post by: rb on December 06, 2009, 17:43:01 pm
This hack uses MooTools' MooPrompt to display the THANK_MESSAGE after sending the email with the question.  I don't know the details of Mynxx, but if your site doesn't include MooPrompt and has some type of replacement, you'll have to change the "document.boxB" code starting at line 44 to use that replacement.
Title: Re: Ask question form included on flypage AJAX
Post by: Ventsi Genchev on December 06, 2009, 20:12:00 pm
Ok, thank you.
Title: Re: Ask question form included on flypage AJAX
Post by: djreason on February 16, 2010, 19:31:18 pm
anyone know how to change the color scheme of the ajax box for the success message that pops up?  right now, it is white on white and cant be read.  what file controls this function?
Title: Re: Ask question form included on flypage AJAX
Post by: rb on February 16, 2010, 20:52:23 pm
The styling for the MooPrompt box is found in:
     components/com_virtuemart/js/mootools/mooPrompt.css

and the contents are styled in components/com_virtuemart/themes/your_theme_name/theme.css
      .shop_info, .shop_warning
Title: Re: Ask question form included on flypage AJAX
Post by: klutzon on March 09, 2010, 23:01:06 pm
Hi there rb,

Got your "Ask-a-question AJAX flypage" mod, and it works very well, thank you very much! :) I have a request though, if you could help (since I've been trying the last hour and I can't seem to get what I'm doing wrong) I'd appreciate it.

What I would like is to display the ask-a-question form on the flypage without having to click to reveal / hide it. That way, I can put the form in a MagicTab along with all other details. So for example, I'll have tabs for "Product Desc", "Related Products", "Additional Files" and "Ask a Question", and I'd like the form to appear in the tab without needing to click on anything to reveal it. What should I modify in the flypage-ask-inline.tpl.php to achieve this effect?

Thanks for the assist in advance! :D
Title: Re: Ask question form included on flypage AJAX
Post by: rb on March 10, 2010, 00:36:35 am
hey klutzon, if you go back and read the first 2 pages of this thread, you'll see that "jjj2" has posted a solution showing this Ajax/inline "Ask a question" form within MagicTabs.

The hide/show is controlled by 4 statements:
1. When the form is first shown, it is hidden by this CSS statement:
Code: [Select]
div.ask_inline {
display:none;
You can remove this (or comment it out as jjj2 did).

2. When the user clicks "Ask a question ...", the form is revealed by that actual link:
Code: [Select]
<a class="button" href="" onclick="document.getElementById('ask_inline').style.display='block';return false;"><?php echo $ask_seller_text?></a>If you haven't already, remove that and make it your tab title.

3. After the email is sent, this JavaScript line re-hides the form:
Code: [Select]
document.getElementById('ask_inline').style.display='none';Again, remove or comment out. jjj2 left it in, I guess so that the user sees it disappeared, confirming in the user's mind that the email was sent.

4. If the user starts to fill out the form, and then changes his/her mind and clicks "Cancel", this action re-hides the form:
Code: [Select]
<input type="button" name="cancel" class="button" value="<?php echo $VM_LANG->_('CMN_CANCEL'); ?>"  onclick="document.getElementById('ask_inline').style.display='none'; return false;">You may wish to replace that with an HTML form "Reset" button.
Title: Re: Ask question form included on flypage AJAX
Post by: klutzon on March 10, 2010, 07:01:54 am
Thank you rb, I didn't see jjj2's post as a solution to my problem, I didn't see the key words I was after associated with his post, but now that I've gone through the code he posted I can see it's to do what I'm looking.

I will go through his code, as well as yours, and see if I can sort this out. I'll be back to report... :)
Title: Re: Ask question form included on flypage AJAX
Post by: mbit on March 30, 2010, 16:55:03 pm
i am using a theme already, i followed the instructions and tryed to add a new tab next to once that exist already.
by editing the template.tmp.php in line78 i created a copy of the previous  if-tab :
Code: [Select]
<?php if( !empty( $ask_seller_text )) { ?>
<div id="tabs"> <a class="button" href="" onclick="document.getElementById('ask_inline').style.display='block';return false;"><?php echo $ask_seller_text?></a>
</div>
<?php ?>
which gave me a new tab but when i click in it , it goes me in main page. i tryed adding the line : <?php include("flypage-ask-inline.tpl.php"); ?> but no result :/ any ideas how i can make it work ?


Thanks in advance,

Mbit

[attachment cleanup by admin]
Title: Re: Ask question form included on flypage AJAX
Post by: rb on March 30, 2010, 18:33:18 pm
I can't tell for sure what you're doing with that small snippet of code, but it sort of looks like you've replaced the code that opens a tab with the code one would use to show the inline "Ask" form on a page without tabs.  The original code hid the inline form.  But if you're using it with tabs, then the tab code hides it.
Title: Re: Ask question form included on flypage AJAX
Post by: mbit on March 30, 2010, 18:56:55 pm
its not the original code because its a another template , not the default . the code that makes the tabs seems to be this one
Code: [Select]

<div id="vmj_product_details_tab">
<?php if( trim(str_replace"<br />""" $product_description)) != "" ) { ?>
<div id="tabs"><a rel="p_description" class="selected"><?php echo $VM_LANG->_('PHPSHOP_PRODUCT_DESC_TITLE'?></a></div>
<?php ?>
<?php if( trim(str_replace"<br />""" $product_reviews)) != "" ) { ?>
<div id="tabs"><a rel="reviews"><?php echo $VM_LANG->_('PHPSHOP_REVIEWS'?></a></div>
<?php ?>
<?php if( trim(str_replace"<br />""" $related_products)) != "" ) { ?>
<div id="tabs"><a rel="related"><?php echo $VM_LANG->_('PHPSHOP_RELATED_PRODUCTS')?></a></div>
<?php ?>
<?php if( !empty( $recent_products )) { ?>
<div id="tabs"><a rel="recent"><?php echo $VM_LANG->_('VM_RECENT_PRODUCTS'?></a></div>
<?php ?>

as i told you i copied from above and created
Code: [Select]

<?php if( !empty( $ask_seller_text )) { ?>
<div id="vmj_tabs"> <a class="button" href="" onclick="document.getElementById('ask_inline').style.display='block';return false;"><?php echo $ask_seller_text?> </a>
</div>
<?php ?>
but not working cause i dont know enough of coding.. any advices are welcome,

thanks in advance
Title: Re: Ask question form included on flypage AJAX
Post by: rb on March 30, 2010, 20:43:39 pm
I'm still unable to figure out what you have coded.  Four different suggestions:

1. Ask your template provider for assistance as they provide the code you are trying to modify.

2. Start over.  Then make a new tab for the "ask question" form, just like the other tabs.  Then copy the contents of the "inline form" into your tab and modify from there.

3. Hire a commercial programmer.

4. There's lots of free PHP tutorials on the web.  See if you can learn how to customize this to your specific needs.
Title: Re: Ask question form included on flypage AJAX
Post by: mbit on April 06, 2010, 14:05:19 pm
i tried your forth option.. the results made the form show up but didnt  make it to hide  :( i tried also to ask the developer but he wants 20$ for 2 lines pff  >:(
i took some screenshot to show u whats going on. If is go from tab description to tab Ask a question about this product
 everything is ok if i go back the form is still there under the description :( . Also if i go from recently viewed product to Ask a question about this product the recently items are shown and back words form still there. i attack the code & the screenshot if anyone has some time and any idea is welcome!


Code: [Select]
<div id=" product_details_tab">
<?php if( trim(str_replace"<br />""" $product_description)) != "" ) { ?>
<div id=" tabs"><a rel="p_description" ><?php echo $VM_LANG->_('PHPSHOP_PRODUCT_DESC_TITLE'?></a></div>
<?php ?>
<?php if( trim(str_replace"<br />""" $product_reviews)) != "" ) { ?>
<div id=" tabs"><a rel="reviews"><?php echo $VM_LANG->_('PHPSHOP_REVIEWS'?></a></div>
<?php ?>
<?php if( trim(str_replace"<br />""" $related_products)) != "" ) { ?>
<div id=" tabs"><a rel="related"><?php echo $VM_LANG->_('PHPSHOP_RELATED_PRODUCTS')?></a></div>
<?php ?>
<?php if( !empty( $recent_products )) { ?>
<div id=" tabs"><a rel="recent"><?php echo $VM_LANG->_('VM_RECENT_PRODUCTS'?></a></div>
<?php ?>



<?php if( trim(str_replace"<br />""" $ask_seller ))  != "" ) { ?>
<div id=" tabs"> <a class="button" href="#" onclick="document.getElementById('p_description').style.display='none';document.getElementById('ask_inline').style.display='block';return false;"><?php echo $ask_seller_text ?> </a>
</div>
<?php ?>
</div>



<div style="clear:both;"></div>
<div style="border:1px solid #BBBBBB; margin-bottom: 1em; padding: 10px">
<?php if( trim(str_replace"<br />""" $product_description)) != "" ) { ?>
<div id="p_description" class=" tabcontent">
<?php echo $product_description ?>
</div>
<?php ?>

<?php if( (include "flypage-ask-inline.tpl.php" ) !="") { ?>
<style>
div.ask_inline {
display:none;
}
</style>

<?php ?>
<?php if( trim(str_replace"<br />""" $product_reviews)) != "" ) { ?>
<div id="reviews" class=" tabcontent">
<?php echo $product_reviews ?>
   <br/><br/>
   <?php echo $product_reviewform ?>
</div>
<?php ?>
<?php if( trim(str_replace"<br />""" $related_products)) != "" ) { ?>
<div id="related" class=" tabcontent">
<?php echo $related_products ?>
</div>
<?php ?>
<?php if( !empty( $recent_products )) { ?>
<div id="recent" class=" tabcontent">
<?php echo $recent_products?>
</div>
<?php }?>

</div>

[attachment cleanup by admin]
Title: Re: Ask question form included on flypage AJAX
Post by: rb on April 06, 2010, 15:42:37 pm
mbit, I looked at your code and it appears quite jumbled to me, so sorry, I'm unable to assist you beyond my 4 suggestions above.
Title: Re: Ask question form included on flypage AJAX
Post by: mbit on April 06, 2010, 18:02:20 pm
is there a way to reveal the form with php?  ???
i am trying something like this but not working :/
Code: [Select]
<?php echo("<document.getElementById('ask_inline').style.display='block';return false;>")?>

this is closer than anything else so far, it reveals me a button when i choose the tab which get me to another page in order to complete the form. Is there a way to reveal the form inside the tab??

Code: [Select]
<?php echo $ask_seller;
 ?>


thanks in advance
Title: Re: Ask question form included on flypage AJAX
Post by: studio16 on May 26, 2010, 11:56:36 am
Hi,

The script works fine only problem is when logged in the email input field is prefilled with java script instead of the emailaddress. Probably the emailcloack plugin of Joomla kicking in:

 <script language='JavaScript' type='text/javascript'> <!-- var prefix = 'ma' + 'il' + 'to'; var path = 'hr' + 'ef' + '='; var addy40464 = 'info' + '@'; addy40464 = addy40464 + 'studio16' + '.' + 'info'; document.write( '<a ' + path + '\'' + prefix + ':' + addy40464 + '\'>' ); document.write( addy40464 ); document.write( '<\/a>' ); //-->\n </script> <script language='JavaScript' type='text/javascript'> <!-- document.write( '<span style=\'display: none;\'>' ); //--> </script>Dit e-mailadres is beschermd tegen spambots. U heeft Javascript nodig om het te kunnen zien. <script language='JavaScript' type='text/javascript'> <!-- document.write( '</' ); document.write( 'span>' ); //--> </script>


any ideas?
Title: Re: Ask question form included on flypage AJAX
Post by: Reincha on July 20, 2010, 20:07:11 pm
Is it possible to add simple captcha to this? something like a one word answer to a question?
Title: Re: Ask question form included on flypage AJAX
Post by: gkovacs on November 25, 2013, 11:25:01 am
Hi!

When i click on send button, i've got this message:
"Your product question was not emailed due to an internal error"

Any help?