Author Topic: Ask question form included on flypage AJAX  (Read 39499 times)

jjj2

  • Jr. Member
  • **
  • Posts: 53
Re: Ask question form included on flypage AJAX
« Reply #15 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.

rb

  • Advanced
  • Hero Member
  • *****
  • Posts: 1503
Re: Ask question form included on flypage AJAX
« Reply #16 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.

jjj2

  • Jr. Member
  • **
  • Posts: 53
Re: Ask question form included on flypage AJAX
« Reply #17 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 :)

rb

  • Advanced
  • Hero Member
  • *****
  • Posts: 1503
Re: Ask question form included on flypage AJAX
« Reply #18 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.

drevokocur

  • Beginner
  • *
  • Posts: 44
Re: Ask question form included on flypage AJAX
« Reply #19 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?? :)

rb

  • Advanced
  • Hero Member
  • *****
  • Posts: 1503
Re: Ask question form included on flypage AJAX
« Reply #20 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);

drevokocur

  • Beginner
  • *
  • Posts: 44
Re: Ask question form included on flypage AJAX
« Reply #21 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. ;)

akeem76

  • Beginner
  • *
  • Posts: 18
Re: Ask question form included on flypage AJAX
« Reply #22 on: December 03, 2009, 09:41:54 am »
may i view your site? :)

Venci Gentchev

  • Jr. Member
  • **
  • Posts: 180
    • Bulgarian Computer Store
Re: Ask question form included on flypage AJAX
« Reply #23 on: December 06, 2009, 16:40:24 pm »
When I try to send a question, I get the following error:

MooPrompt is not defined
No pain, no gain, no site!

rb

  • Advanced
  • Hero Member
  • *****
  • Posts: 1503
Re: Ask question form included on flypage AJAX
« Reply #24 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"

Venci Gentchev

  • Jr. Member
  • **
  • Posts: 180
    • Bulgarian Computer Store
Re: Ask question form included on flypage AJAX
« Reply #25 on: December 06, 2009, 17:05:06 pm »
Yes, it is set to "Yes".
I use mynxx template from Rocket.
No pain, no gain, no site!

rb

  • Advanced
  • Hero Member
  • *****
  • Posts: 1503
Re: Ask question form included on flypage AJAX
« Reply #26 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.

Venci Gentchev

  • Jr. Member
  • **
  • Posts: 180
    • Bulgarian Computer Store
Re: Ask question form included on flypage AJAX
« Reply #27 on: December 06, 2009, 20:12:00 pm »
Ok, thank you.
No pain, no gain, no site!

djreason

  • Jr. Member
  • **
  • Posts: 125
    • Game Room and Man Cave Supplies
Re: Ask question form included on flypage AJAX
« Reply #28 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?

rb

  • Advanced
  • Hero Member
  • *****
  • Posts: 1503
Re: Ask question form included on flypage AJAX
« Reply #29 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