News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Print icon at product details pop window does not print [SOLVED]

Started by Georgios Kolomvos, May 19, 2012, 09:21:02 AM

Previous topic - Next topic

Georgios Kolomvos

I use Joomla 2.5.4 and VM 2.0.6
When a user clicks on the print icon button in a product's detail page, a pop up window appears with the same print icon. The user clicks on that print icon and the product page is not printed as expected.
Fortunatelly i have found a workaround in two steps (code modifications are marked with green characters):

1) Edit file: "components/com_virtuemart/helpers/vmview.php" and change code:
//===========================
function linkIcon($link,$altText ='',$boutonName,$verifyConfigValue=false, $modal = true, $use_icon=true,$use_text=false) {
   if ($verifyConfigValue) {
      if ( !VmConfig::get($verifyConfigValue, 0) ) return '';
   }
   $folder = (JVM_VERSION===1) ? '/images/M_images/' : '/media/system/images/';
   $text='';
   if ( $use_icon ) $text .= JHtml::_('image.site', $boutonName.'.png', $folder, null, null, JText::_($altText));
   if ( $use_text ) $text .= ' '. JText::_($altText);
   if ( $text=='' )  $text .= ' '. JText::_($altText);
   if ($modal) return '<a class="modal" rel="{handler: \'iframe\', size: {x: 700, y: 550}}" title="'. JText::_($altText).'" href="'.JRoute::_($link).'">'.$text.'</a>';
   else return '<a title="'. JText::_($altText).'" href="'.JRoute::_($link).'">'.$text.'</a>';
   }
//===========================
to:
//===========================
function linkIcon($link,$altText ='',$boutonName,$verifyConfigValue=false, $modal = true, $use_icon=true,$use_text=false, $is_print_pop=false) {
   if ($verifyConfigValue) {
      if ( !VmConfig::get($verifyConfigValue, 0) ) return '';
   }
   $folder = (JVM_VERSION===1) ? '/images/M_images/' : '/media/system/images/';
   $text='';
   if ( $use_icon ) $text .= JHtml::_('image.site', $boutonName.'.png', $folder, null, null, JText::_($altText));
   if ( $use_text ) $text .= '&nbsp;'. JText::_($altText);
   if ( $text=='' )  $text .= '&nbsp;'. JText::_($altText);
   if ($modal) return '<a class="modal" rel="{handler: \'iframe\', size: {x: 700, y: 550}}" title="'. JText::_($altText).'" href="'.JRoute::_($link).'">'.$text.'</a>';
   elseif ($is_print_pop) return '<a title="'. JText::_($altText).'" href="javascript:void(0)" onclick="javascript:window.print(); return false;">'.$text.'</a>';
   else return '<a title="'. JText::_($altText).'" href="'.JRoute::_($link).'">'.$text.'</a>';
//===========================

2) Copy the file "components/com_virtuemart/views/productdetails/tmpl/default.php" to your template directory at folder: templates/my_Joomla_template/html/com_virtuemart/productdetails/

Edit file  templates/my_Joomla_template/html/com_virtuemart/productdetails/default.php and and substitute line (~104):
//===========================
    echo $this->linkIcon($link . '&print=1', 'COM_VIRTUEMART_PRINT', 'printButton', 'show_printicon');
//===========================

with the following piece of code:
//===========================
    $isPopup = JRequest::getVar( 'pop' );
    if ( $isPopup ) {
   // Print Preview button - used in pop-up window
   echo $this->linkIcon('', 'COM_VIRTUEMART_PRINT', 'printButton', 'show_printicon', false,true,false, true);
    } else {
   // Print Button - used when viewing page
   echo $this->linkIcon($link . '&print=1&pop=1', 'COM_VIRTUEMART_PRINT', 'printButton', 'show_printicon');
    }

//===========================
Georgios Kolomvos
Patras, Greece

zebrafilm

Tried your solution but it did not work for me.
I see no changes so somehow it does not get picked up.

Would be great to get this problem solved.

Bastiaan

Georgios Kolomvos

Quote from: zebrafilm on May 30, 2012, 13:55:21 PM
Tried your solution but it did not work for me.
I see no changes so somehow it does not get picked up.

In step 2 of my instructions, try to modify directly the file "components/com_virtuemart/views/productdetails/tmpl/default.php", instead of copying it to "templates/my_Joomla_template/html/com_virtuemart/productdetails/default.php"
Georgios Kolomvos
Patras, Greece

zebrafilm

Your help is much appreciated but I am sure my overrides work. It is also bad practice to alter the VM files directly, especially because there is a new update every week :-)

Bastiaan


werian

Here is my code with "auto showed" print page:

Edit: /components/com_virtuemart/helpers/vmview.php

Change lines:
if ($modal) return '<a class="modal" rel="{handler: \'iframe\', size: {x: 700, y: 550}}" title="'. JText::_($altText).'" href="'.JRoute::_($link).'">'.$text.'</a>';
else return '<a title="'. JText::_($altText).'" href="'.JRoute::_($link).'">'.$text.'</a>';


to:

if ($modal)
{
if($boutonName == 'printButton' && isset($_REQUEST['print']))
{
$js = "
window.addEvent('domready', function(){
   window.print();
});
";
$doc = JFactory::getDocument();
$doc->addScriptDeclaration( $js );
return '<a title="'. JText::_($altText).'" href="javascript:void(0)" onclick="javascript:window.print(); return false;">'.$text.'</a>';
}
else if($boutonName != 'printButton' && isset($_REQUEST['print']))
return '';
else
return '<a class="modal" rel="{handler: \'iframe\', size: {x: 700, y: 550}}" title="'. JText::_($altText).'" href="'.JRoute::_($link).'">'.$text.'</a>';
}
else return '<a title="'. JText::_($altText).'" href="'.JRoute::_($link).'">'.$text.'</a>';

isuv

Hi,
I've tried the code from gkolomvos with Joomla 2.5.9 and VM 2.0.16 installation. It works! When I press print icon, pop-up opens. When I press print icon in the pop-up window, it is printed.

Spiros Petrakis

There is no need to modify the core files to fix the print button function you can easily do it by only modifying the products details page .

Find lines 109 to 122 in file components/com_virtuemart/views/productdetails/tmpl/default.php or in your templates override file 


<div class="icons">
    <?php
    
//$link = (JVM_VERSION===1) ? 'index2.php' : 'index.php';
    $link 'index.php?tmpl=component&option=com_virtuemart&view=productdetails&virtuemart_product_id=' $this->product->virtuemart_product_id;
    $MailLink 'index.php?option=com_virtuemart&view=productdetails&task=recommend&virtuemart_product_id=' $this->product->virtuemart_product_id '&virtuemart_category_id=' $this->product->virtuemart_category_id '&tmpl=component';

    if (VmConfig::get('pdf_icon'1) == '1') {
echo $this->linkIcon($link '&format=pdf''COM_VIRTUEMART_PDF''pdf_button''pdf_button_enable'false);
    }
    echo $this->linkIcon($link '&print=1''COM_VIRTUEMART_PRINT''printButton''show_printicon');
    echo $this->linkIcon($MailLink'COM_VIRTUEMART_EMAIL''emailButton''show_emailfriend');
    ?>

    <div class="clear"></div>
        </div>



and replace it with this



        <div class="icons">
    <?php
    
//$link = (JVM_VERSION===1) ? 'index2.php' : 'index.php';
        
if (JRequest::getVar'print' ) == 1) {

           
$link '"#" onclick="window.print(); return false;"';

        } else {

           
$link 'index.php?tmpl=component&option=com_virtuemart&view=productdetails&virtuemart_product_id=' $this->product->virtuemart_product_id;

        }
    $MailLink 'index.php?option=com_virtuemart&view=productdetails&task=recommend&virtuemart_product_id=' $this->product->virtuemart_product_id '&virtuemart_category_id=' $this->product->virtuemart_category_id '&tmpl=component';

        if (
JRequest::getVar'print' ) == ) {

        echo 
$this->linkIcon($link '&print=1''COM_VIRTUEMART_PRINT''printButton''show_printicon'false);

        } else {

        if (
VmConfig::get('pdf_icon'1) == '1') {
echo $this->linkIcon($link '&format=pdf''COM_VIRTUEMART_PDF''pdf_button''pdf_button_enable'false);
        }
        echo 
$this->linkIcon($link '&print=1''COM_VIRTUEMART_PRINT''printButton''show_printicon');
        echo 
$this->linkIcon($MailLink'COM_VIRTUEMART_EMAIL''emailButton''show_emailfriend');

        }

        
?>

    <div class="clear"></div>
        </div>


Joomla templates and extensions development
https://www.yourgeek.gr

Milbo

Thx

sorry for seeing this so late. I just added the possibility to use the $class option also in the modal option of the linkIcon function

I added now to the layout

if(JRequest::getInt('print',false)){
$print = 'onclick="window.print(); return false;"';
} else {
$print = '';
}
    echo $this->linkIcon($link . '&print=1', 'COM_VIRTUEMART_PRINT', 'printButton', 'show_printicon',true,true,false,$print);


Will be in vm2.0.24a
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Milbo

found an easier solution, just add to the default.php at begin

if(JRequest::getInt('print',false)){
?>
<body onload="javascript:print();">
<?php }
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/