VirtueMart Forum

VirtueMart 2 + 3 + 4 => General Questions => Topic started by: krakoukass on March 15, 2012, 16:52:29 PM

Title: replace link to productdetails by link to ask-a-question
Post by: krakoukass on March 15, 2012, 16:52:29 PM
Bonjour, lors de l'affichage de la liste des produits, je souhaite que le lien de chaque item n'ouvre pas la page productdetails mais fasse comme le bouton ask-a-question.

J'ai repéré le code dans chaque php mais comment mettre cela ensemble ?

Merci d'avance

Hi ! in the list of products from 1 category, I don't wish a link near productdetails but like the button ask-a-question : click on the product name open the form.

Is it possible ?

Thank you
Title: Re: replace link to productdetails by link to ask-a-question
Post by: PRO on March 15, 2012, 20:05:13 PM
url = JRoute::_('index.php?option=com_virtuemart&view=productdetails&task=askquestion&virtuemart_product_id=' . $product->virtuemart_product_id . '&virtuemart_category_id=' . $product->virtuemart_category_id);

Title: Re: replace link to productdetails by link to ask-a-question
Post by: Rayjak on July 04, 2012, 17:34:30 PM
I wish to do the same thing but don't understand your reply.

How does your reply fit into or replace this code:

               <?php // Product Details Button
               echo JHTML::link($product->link, JText::_('COM_VIRTUEMART_PRODUCT_DETAILS'), array('title' => $product->product_name,'class' => 'product-details'));               
               ?>

Thank you.
Title: Re: replace link to productdetails by link to ask-a-question
Post by: babouz on August 10, 2012, 11:41:39 AM
Quote from: PRO on March 15, 2012, 20:05:13 PM
url = JRoute::_('index.php?option=com_virtuemart&view=productdetails&task=askquestion&virtuemart_product_id=' . $product->virtuemart_product_id . '&virtuemart_category_id=' . $product->virtuemart_category_id);

Hi,
I try to do the same things but it seems to doesn't work...

I put your code and all the code at the top of productdetails/default.php to the top of category/default.php :

$url = JRoute::_('index.php?option=com_virtuemart&view=productdetails&task=askquestion&virtuemart_product_id=' . $product->virtuemart_product_id . '&virtuemart_category_id=' . $product->virtuemart_category_id . '&tmpl=component');


$document = JFactory::getDocument();

$document->addScriptDeclaration("

jQuery(document).ready(function($) {

$('a.ask-a-question').click( function(){

$.facebox({

iframe: '" . $url . "',

rev: 'iframe|550|550'

});

return false ;

});

/* $('.additional-images a').mouseover(function() {

var himg = this.href ;

var extension=himg.substring(himg.lastIndexOf('.')+1);

if (extension =='png' || extension =='jpg' || extension =='gif') {

$('.main-image img').attr('src',himg );

}

console.log(extension)

});*/

});

");


Now I got the popup when I clic on "Ask question" but form is not display...
(http://nsa30.casimages.com/img/2012/08/10/mini_120810115214683532.jpg) (http://www.casimages.com/img.php?i=120810115214683532.jpg)

Can you help me please ?
Title: Re: replace link to productdetails by link to ask-a-question
Post by: babouz on August 13, 2012, 09:51:11 AM
Up !
Someone can help me please ?
Title: Re: replace link to productdetails by link to ask-a-question
Post by: babouz on August 13, 2012, 12:05:20 PM
Quote from: krakoukass on March 15, 2012, 16:52:29 PM
Bonjour, lors de l'affichage de la liste des produits, je souhaite que le lien de chaque item n'ouvre pas la page productdetails mais fasse comme le bouton ask-a-question.

J'ai repéré le code dans chaque php mais comment mettre cela ensemble ?

Merci d'avance

Hi ! in the list of products from 1 category, I don't wish a link near productdetails but like the button ask-a-question : click on the product name open the form.

Is it possible ?

Thank you

Bonjour Krakoukass, je souhaite faire exactement la même chose !
Avez-vous trouvé une solution depuis le mois de mars ?
Moi j'arrive à afficher le pop up du formulaire mais sans le formulaire...   :(

Merci d'avance pour votre réponse
Title: Re: replace link to productdetails by link to ask-a-question
Post by: PRO on August 13, 2012, 15:32:50 PM
Quote from: babouz on August 10, 2012, 11:41:39 AM
Quote from: PRO on March 15, 2012, 20:05:13 PM
url = JRoute::_('index.php?option=com_virtuemart&view=productdetails&task=askquestion&virtuemart_product_id=' . $product->virtuemart_product_id . '&virtuemart_category_id=' . $product->virtuemart_category_id);

Hi,
I try to do the same things but it seems to doesn't work...

I put your code and all the code at the top of productdetails/default.php to the top of category/default.php :

$url = JRoute::_('index.php?option=com_virtuemart&view=productdetails&task=askquestion&virtuemart_product_id=' . $product->virtuemart_product_id . '&virtuemart_category_id=' . $product->virtuemart_category_id . '&tmpl=component');


$document = JFactory::getDocument();

$document->addScriptDeclaration("

jQuery(document).ready(function($) {

$('a.ask-a-question').click( function(){

$.facebox({

iframe: '" . $url . "',

rev: 'iframe|550|550'

});

return false ;

});

/* $('.additional-images a').mouseover(function() {

var himg = this.href ;

var extension=himg.substring(himg.lastIndexOf('.')+1);

if (extension =='png' || extension =='jpg' || extension =='gif') {

$('.main-image img').attr('src',himg );

}

console.log(extension)

});*/

});

");


Now I got the popup when I clic on "Ask question" but form is not display...
(http://nsa30.casimages.com/img/2012/08/10/mini_120810115214683532.jpg) (http://www.casimages.com/img.php?i=120810115214683532.jpg)

Can you help me please ?


You could try a javascript popup

<a class="quote" href="<?php echo $url ?>" onclick="window.open(this.href,'targetWindow','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes, width=600, height=800');return false;" ><?php echo JText::_('COM_VIRTUEMART_PRODUCT_ENQUIRY_LBL') ?></a>

OR: MAKE sure the

$url=

IS INSIDE the foreach ($products as $product){


}
Title: Re: replace link to productdetails by link to ask-a-question
Post by: babouz on August 16, 2012, 10:54:48 AM
Hi,
First of all thank you for your answer  :)

You were right, I've moved $url inside "foreach ( $this->products as $product ) { }" and replaced the link by a basic javascript pop up and now it's works !
So I've moved the lightbox code under the $url and now I have the lighbox popup with the form !  ;D

BUT ! It's always the last one product of the list which is displayed.....  :(

Have you an idea ?
Title: Re: replace link to productdetails by link to ask-a-question
Post by: babouz on August 20, 2012, 09:34:35 AM
Quote from: PRO on August 13, 2012, 15:32:50 PM
You could try a javascript popup

<a class="quote" href="<?php echo $url ?>" onclick="window.open(this.href,'targetWindow','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes, width=600, height=800');return false;" ><?php echo JText::_('COM_VIRTUEMART_PRODUCT_ENQUIRY_LBL') ?></a>

OR: MAKE sure the

$url=

IS INSIDE the foreach ($products as $product){


}


In fact, it seems to have a problem with facebox code...

all works fine when I remove this code :


$document->addScriptDeclaration("

jQuery(document).ready(function($) {

$('a.ask-a-question').click( function(){

$.facebox({

iframe: '" . $url . "',

rev: 'iframe|550|550'

});

return false ;

});

});

");


I see the product's form but without the facebox popup style...
Do you know what's wrong in this code ? I'm not really good in jquery...

Thx for your help !
Title: Re: replace link to productdetails by link to ask-a-question
Post by: PRO on August 20, 2012, 17:59:59 PM
babouz, I cannot test this, because I dont use the lightbox. I use a regular popup
Title: Re: replace link to productdetails by link to ask-a-question
Post by: ivus on August 20, 2012, 22:17:25 PM
Hi babouz,

What page did you want to display this ASK-A-QUESTION pop up?

Is it the category page? if so you cannot use that particular $document->addScripDeclaration() on that page as it hard codes a single URL to the pop-up action

You'll need to combine PRO's original code with the following:



   <?php $url JRoute::_('index.php?option=com_virtuemart&view=productdetails&task=askquestion&virtuemart_product_id=' $product->virtuemart_product_id '&virtuemart_category_id=' $product->virtuemart_category_id); ?>
   <a class="modal" rel="{handler: 'iframe', size: {x: 700, y: 550}}" href="<?php echo $url ?>"><?php echo JText::_('COM_VIRTUEMART_PRODUCT_ENQUIRY_LBL'?></a>



Remember it has to go inside that foreach loop...

Give that a go. :D
Title: Re: replace link to productdetails by link to ask-a-question
Post by: babouz on August 21, 2012, 10:06:46 AM
Hi ivus,
Yes I would like to have "ask a question" on category page. And now because of you it works !!! Yeeeesss !

In fact I've deleted all I had made before and just put your last one code instead of mine.

But It had displayed a lighbox popup with a frame of my website which displayed the good form  :o
So I just added to your code "&tmpl=component" and now it works great (I don't really know why... if someone can explain).

Now my code :

<?php $url JRoute::_('index.php?option=com_virtuemart&view=productdetails&task=askquestion&virtuemart_product_id=' $product->virtuemart_product_id '&virtuemart_category_id=' $product->virtuemart_category_id '&tmpl=component'); ?>
   <a class="modal ask-a-question" rel="{handler: 'iframe', size: {x: 550, y: 550}}" href="<?php echo $url ?>"><?php echo JText::_('COM_VIRTUEMART_PRODUCT_ENQUIRY_LBL'?></a>
Title: Re: replace link to productdetails by link to ask-a-question
Post by: ivus on August 21, 2012, 10:10:16 AM
Hi babouz,

That's wonderful. Good stuff.

&tmpl=component is a template override switch. Basically it will display only the COMPONENT part of the page and bypass the rendering of any other elements (headers, modules etc).
Title: Re: replace link to productdetails by link to ask-a-question
Post by: babouz on August 21, 2012, 11:22:44 AM
Ok, thank you ivus for your explanation and for your help ;)