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

rb

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

PRO

  • Global Moderator
  • Super Hero
  • *
  • Posts: 10272
  • VirtueMart Version: 3+
Ask question form included on flypage AJAX
« Reply #1 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
I do NOT do development work for hire.

jjj2

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

PRO

  • Global Moderator
  • Super Hero
  • *
  • Posts: 10272
  • VirtueMart Version: 3+
Re: Ask question form included on flypage AJAX
« Reply #3 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
I do NOT do development work for hire.

jjj2

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

aravot

  • Peter
  • Quality&Testing Team
  • Hero Member
  • *
  • Posts: 2874
    • VirtueMart Extensions
Re: Ask question form included on flypage AJAX
« Reply #5 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

rb

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

jjj2

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

rb

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

Intel386

  • Beginner
  • *
  • Posts: 3
Re: Ask question form included on flypage AJAX
« Reply #9 on: October 27, 2009, 02:29:33 am »
Thanks aboaut solution !But how to intergrated with plug_in rokbox ?

rb

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

jjj2

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

rb

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

jjj2

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

rb

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