Jump to content

Ayuda con Link.php


JuDrYa

Recommended Posts

Hola a tod@s.

Estoy intentando implementar lo siguiente en mi web...

http://www.prestashop.com/forums/topic/272119-guide-rollover-images-on-product-lists/?do=findComment&comment=1362940

 

El primer paso seria pegar el archivo "Link.php" en "override/classes"

LINK.PHP

<?php
class Link extends LinkCore
{
/**
* Returns a link to a product image for display
* Note: the new image filesystem stores product images in subdirectories of img/p/
*
* @param string $name rewrite link of the image
* @param string $ids id part of the image filename - can be "id_product-id_image" (legacy support, recommended) or "id_image" (new)
* @param string $type
* @param integer $rollover id of current product
*/
public function getImageLink($name, $ids, $type = null, $rollover = null)
{
$not_default = false;
// legacy mode or default image
$theme = ((Shop::isFeatureActive() && file_exists(_PS_PROD_IMG_DIR_.$ids.($type ? '-'.$type : '').'-'.(int)Context::getContext()->shop->id_theme.'.jpg')) ? '-'.Context::getContext()->shop->id_theme : '');
if ((Configuration::get('PS_LEGACY_IMAGES')
&& (file_exists(_PS_PROD_IMG_DIR_.$ids.($type ? '-'.$type : '').$theme.'.jpg')))
|| ($not_default = strpos($ids, 'default') !== false))
{
if ($this->allow == 1 && !$not_default)
$uri_path = __PS_BASE_URI__.$ids.($type ? '-'.$type : '').$theme.'/'.$name.'.jpg';
else
$uri_path = _THEME_PROD_DIR_.$ids.($type ? '-'.$type : '').$theme.'.jpg';
}
else
{
// if ids if of the form id_product-id_image, we want to extract the id_image part
$split_ids = explode('-', $ids);
$id_image = (isset($split_ids[1]) ? $split_ids[1] : $split_ids[0]);
$theme = ((Shop::isFeatureActive() && file_exists(_PS_PROD_IMG_DIR_.Image::getImgFolderStatic($id_image).$id_image.($type ? '-'.$type : '').'-'.(int)Context::getContext()->shop->id_theme.'.jpg')) ? '-'.Context::getContext()->shop->id_theme : '');
if(isset($rollover))
{
$hover_image = Db::getInstance()->getRow('SELECT id_image FROM '._DB_PREFIX_.'image WHERE id_product = '.$rollover.' AND position = 1');
 
if($hover_image)
$id_image = array_shift($hover_image);
else
return '0';
}
 
if ($this->allow == 1)
$uri_path = __PS_BASE_URI__.$id_image.($type ? '-'.$type : '').$theme.'/'.$name.'.jpg';
else
$uri_path = _THEME_PROD_DIR_.Image::getImgFolderStatic($id_image).$id_image.($type ? '-'.$type : '').$theme.'.jpg';
}
 
return $this->protocol_content.Tools::getMediaServer($uri_path).$uri_path;
}
}

Pero resulta que en la ruta "override/classes" ya tengo un archivo "Link.php" la cual ya contiene la función "public function getImageLink($name, $ids, $type = null, $rollover = null)"....

	public function getImageLink($name, $ids, $type = NULL, $idOver= NULL)
	{
		global $protocol_content;
		
		/* CUSTOM */
		if(isset($idOver))
		{
			$result = Db::getInstance()->ExecuteS('SELECT id_image FROM ps_image WHERE id_product = '.$idOver.' AND position = 2');
			foreach ($result as $row)
			$id_image_over = $row['id_image'];
		}
		else
		{
			$id_image_over = 0;
		}

		// legacy mode or default image
		if ((Configuration::get('PS_LEGACY_IMAGES') 
			&& (file_exists(_PS_PROD_IMG_DIR_.$ids.($type ? '-'.$type : '').'.jpg')))
			|| strpos($ids, 'default') !== false)
		{
			$split_ids = explode('-', $ids);
			$newIds1 = $split_ids[1] + 1;
			$idsArray = array($split_ids[0], $newIds1);
			$newIds = implode('-', $idsArray);
			
			if($id_image_over != 0)
			{
				$id_image = $id_image_over;
				if ($this->allow == 1)
					$uri_path = __PS_BASE_URI__.$newIds.($type ? '-'.$type : '').'/'.$name.'.jpg';
				else
					$uri_path = _THEME_PROD_DIR_.$newIds.($type ? '-'.$type : '').'.jpg';
			}
			else
			{
				if ($this->allow == 1)
					$uri_path = __PS_BASE_URI__.$ids.($type ? '-'.$type : '').'/'.$name.'.jpg';
				else
					$uri_path = _THEME_PROD_DIR_.$ids.($type ? '-'.$type : '').'.jpg';
			}
		}else
		{
			// if ids if of the form id_product-id_image, we want to extract the id_image part
			$split_ids = explode('-', $ids);
			
			// $id_image = (isset($split_ids[1]) ? $split_ids[1] : $split_ids[0]);
			if($id_image_over != 0)
			{
				$id_image = $id_image_over;
			}
			else
			{	
				$id_image = (isset($split_ids[1]) ? $split_ids[1] : $split_ids[0]);
			}
			
			if ($this->allow == 1)
				$uri_path = __PS_BASE_URI__.$id_image.($type ? '-'.$type : '').'/'.$name.'.jpg';
			else
				$uri_path = _THEME_PROD_DIR_.Image::getImgFolderStatic($id_image).$id_image.($type ? '-'.$type : '').'.jpg';
		}
		
		return $protocol_content.Tools::getMediaServer($uri_path).$uri_path;
	}

Como puedo añadir lo primero a lo segundo.

 

 

Gracias.

Link to comment
Share on other sites

Gracias por contestar "galindogadea".

 

Me llevo faltal con el ingles (malo para moverte por este mundillo :unsure: :unsure: ).

 

He leido esto...

http://www.prestashop.com/forums/topic/272119-guide-rollover-images-on-product-lists/?do=findComment&comment=1623687

 

Gracias por todo.

 

 

NOTA_ La cosa es que ese override del archivo link, no lo he hecho yo, esta de la instalación de presta. No recuerdo haberlo puesto yo.

Edited by JuDrYa (see edit history)
Link to comment
Share on other sites

  • nadie locked this topic
Guest
This topic is now closed to further replies.
×
×
  • Create New...