display image when onmouseover

cachousam

Avatar: cachousam

2012-02-09 07:51

Hello,
How can I display a product image when the mouse is on its name.
For example in the list of the basket.
I think the solution is in the file orders_basket.tpl ,perhaps with a function call.
Thanks

» Quick.Cart v3.x

cachousam

Avatar: cachousam

2012-02-10 09:46

I was wrong.

By searching on some site, I think I'll find the solution.
I downloaded the script wz_tooltip.js.
I put in the core file.
In the template.tpl you want, I place the following code:

in the HEAD:
<script type="text/javascript" src="$config[dir_core]wz_tooltip.js"></script>

where you want to display the image:

<a href="#"onMouseOver ="tooltip(event,'$config[dir_files]$aData[sImage]');"onMouseOut="tooltipdown();"></a&g t;$aData[sName]

But it does not work.
The image is not displayed. Is this the correct address of the image file?

Can you help me a little?
thank you

cachousam

Avatar: cachousam

2012-02-10 11:10

Or maybe a forgotten line in file template/defaut.css?

cachousam

Avatar: cachousam

2012-02-10 13:01

On the site of the developer,i have found many errors in my code.
i try a new line later.

cachousam

Avatar: cachousam

2012-02-11 08:23

That's it. It works. I make this:
I downloaded the script wz_tooltip.js.
I put in the core file.
In the template.tpl you want, I place the following code:

inside the BODY section
<script type="text/javascript" src="$config[dir_core]wz_tooltip.js"></script>

where you want to display the image:

<a href="#"onmouseover ="Tip('<img src=\'$config[dir_files]af8031e2bc.jpg\'>') "onmouseout="UnTip()">$aData[sName]</a>

But if i put this line it does not work:

<a href="#"onmouseover ="Tip('<img src=\'$config[dir_files]$aDataImage[iSizeValue1]\'>') "onmouseout="UnTip()">$aData[sName]</a>

My question is, as in a cart the images are not always the same, what is the address of an image in the database relating to the product.

thank you very much

boboo

Avatar: boboo

2012-02-12 07:40

You have to generate the link to images, beacause it is not there.
In function listProducts in core/orders.php
This function is responsible for creating product list in basket and on the orderPage.

The easiest way: in the above file/function over the line:
foreach( $this->aProducts as $aData ){
add:
$oFile=Files::getInstance();
then in the loop over the $aData['sLinkDelete'] = defined(....
add:
$aData['sFileName']=$oFile->aFilesImages[2][$oFile->aImagesDefault[2][$aData['iProduct']]]['sFil eName'];
Now you have the file name in the $aData sent to templates. You need to add the directory (small or bigger thumbs or even the big ones), alt, title (or what you need) in the img tag.

In your example above just exchange:
$config[dir_files]$aDataImage[iSizeValue1]
to:
$config[dir_files]$aData[sFileName]
This will give you the original big images.
Adding the thumb directory (100, 150 or whatever thumbs sizes you have) between dir_files and fileName you can display the small thumbs.
$config[dir_files]100/$aData[sFileName]
This "100" you can put just "hard wired" or create this in the listProducts.

Additionally you should build in some "security" queries in this function (does the image exist? and so on).

http://qc-plugins.kimla.de

cachousam

Avatar: cachousam

2012-02-12 09:48

Thanks Boboo for your help.
Yesterday i have read this post and it dont work too.

http://opensolution.org/Quick.Cart/forum/how-to-display-products-image-in-basket,5571.html

I have made all of your script but it dont work

in this line the end is false or not?
$aData['sFileName']=$oFile->aFilesImages[2][$oFile->aImagesDefault[2][$aData['iProduct']]]['sFil eName'];

['sFil eName'] or ['sFileName']

I have try the 2 solutions but it is the same result

Thanks for your time

boboo

Avatar: boboo

2012-02-12 10:47

without space.
sFileName

And I use this solution
http://forum.de.selfhtml.org/archiv/2007/4/t150402/

http://qc-plugins.kimla.de

cachousam

Avatar: cachousam

2012-02-13 07:22

Hello,
I must be stupid!
Here is the core file / order.php changed.Do I made &#8203;&#8203;a mistake?


* @param string $sBlock
*/
function listProducts( $sFile, $iId = null, $sBlock = null ){
$oTpl =& TplParser::getInstance( );
$content = null;

if( !isset( $this->aProducts ) ){
if( !isset( $iId ) ){
$this->generateBasket( );
}
else{
$this->generateProducts( $iId );
}
}

if( !isset( $sBlock ) )
$sBlock = 'BASKET_';

if( isset( $this->aProducts ) ){
$i = 0;
$iCount = count( $this->aProducts );
$oFile=Files::getInstance();

foreach( $this->aProducts as $aData ){
$aData['iStyle'] = ( $i % 2 ) ? 0: 1;
$aData['sStyle'] = ( $i == ( $iCount - 1 ) ) ? 'L': $i + 1;
$aData['sSummary'] = displayPrice( normalizePrice( $aData['fSummary'] ) );
$aData['sPrice'] = displayPrice( $aData['fPrice'] );
$aData['sFileName']=$oFile->aFilesImages[2][$oFile->aImagesDefault[2][$aData['iProduct']]]['sF ileName'];

$aData['sLinkDelete'] = defined( 'CUSTOMER_PAGE' ) ? $GLOBALS['aData']['sLinkName'].'&amp;iProductDelete='.$aData['iProduct'] : null;
$oTpl->setVariables( 'aData', $aData );
$content .= $oTpl->tbHtml( $sFile, $sBlock.'LIST' );
$i++;
}

In my file. tpl with this line it works:
<a href="#"onMouseOver ="tooltip('$config[dir_files]100/af8031e2bc.jpg') ;"onMouseOut="tooltipdown();">

But with her it dont work:
<a href="#"onMouseOver ="tooltip('$config[dir_files]100/ ['sFileName']'

) ;"onMouseOut="tooltipdown();">

thanks

cachousam

Avatar: cachousam

2012-02-13 07:26

oopps,I meant:

$config[dir_files]100/$aData[sFileName]

cachousam

Avatar: cachousam

2012-02-13 18:38

That's it!
Everything is good.
I did not write the code in the proper function of the order.php file
I thank you from my heart Boboo.
The only thing left to do is to place the image on the right of my mouse.
The solution should be in this line in tooltip code:
<div id=output style=position:absolute; display:none; ></div>

I'm worse than you, but very good student. I'm really addict of this cms.

boboo

Avatar: boboo

2012-02-13 23:03

This I put into common.js
function tooltip(evt,id){
gEBI('output').innerHTML='<img src='+id+' />';
var e=(window.event)?window.event:evt;
gEBI('output').style.top=parseInt(e.clientY)-100+'px';
gEBI('output').style.left=e.clientX+parseInt(50)+'px';
gEBI('output').style.display='block';
}
function tooltipdown(){
gEBI('output').style.display="none";
}
and this into container.tpl
<div id="output" style="position:fixed;display:none;z-index:1;"></div>
direct under <body> in both blocks: ORDER_BODY & BODY

If you use addition (+) in .js don't forget to parseInt() the added value, otherwise the value will be append (100+50->10050).

And in the products list of basket & orderForm
<a href="#(or link to product)" onMouseOver="tooltip(event,'$aData[sFileName]');" onMouseOut="tooltipdown();">$aData[sName]</a>

http://qc-plugins.kimla.de

Back to top
about us | contact