2017-09-18 5 views
0

엄지 손가락 이미지와 함께 카테고리 페이지에 각 제품의 첫 번째 추가 이미지를 표시하려면이 작업을 수행하는 방법을 알고 있습니까?Opencart 2.1.3 | category.tpl에 엄지 손가락과 함께 하나의 추가 이미지 표시

컨트롤러의 category.php가 category.tpl보기로 호출 할 수 있도록 추가 이미지를로드해야하지만 코딩 지식이 충분하지 않다는 것을 알고 있습니다. 제품의 코드를 사용해 보았지만 추가 이미지가 어떻게 호출되는지 확실하지 않습니다.

도움이 될 것입니다.

답변

1

OpenCart 버전 2.1.3은 없지만 카테고리 페이지에서 첫 번째 추가 이미지를 표시하는 방법은 다음과 같습니다. category.php에서

찾기 :

$data['products'][] = array(
    'product_id' => $result['product_id'], 
    'thumb'  => $image, 

을 교체 :

<?php if($product['thumb2']){ ?><img src="<?php echo $product['thumb2']; ?>"><?php } ?> 
,691 다음 foreach 그것을 사용 내부 category.tpl에 그런

$image_results = $this->model_catalog_product->getProductImages($result['product_id']); 

if ($image_results) { 
    $image2 = $this->model_tool_image->resize($image_results[0]['image'], $this->config->get($this->config->get('config_theme') . '_image_product_width'), $this->config->get($this->config->get('config_theme') . '_image_product_height')); 
} else { 
    $image2 = false; 
} 

$data['products'][] = array(
    'product_id' => $result['product_id'], 
    'thumb'  => $image, 
    'thumb2'  => $image2, 

나는 이것을 OpenCart 2.3.0.2와 함께 테스트했다.

Source