Php opencart上的类别条件标记

Php opencart上的类别条件标记,php,opencart,Php,Opencart,我正在使用opencart v.1.5.1和 /目录/视图/主题/默认值/模板/产品/类别.tpl if (isset($topCatImage)) { show this image } else { show other image } 我如何编写这样的条件: If main current display is of a parent category: show this image else (if it's a subcategory display ): show

我正在使用opencart v.1.5.1和 /目录/视图/主题/默认值/模板/产品/类别.tpl

if (isset($topCatImage)) {
   show this image
} else {
   show other image
}
我如何编写这样的条件:

If main current display is of a parent category:
show this image

else (if it's a subcategory display ):
show different image
因为这就是我想要实现的目标:

在此网站上(父类别): 这是一个横幅图像

关于子类别:
这是一张右侧有描述的图像

还没有测试,但这应该适合您。
在controller/product/category.php上尝试此操作,然后在$this->data['products']=array()之前

论第三方物流

if (isset($topCatImage)) {
   show this image
} else {
   show other image
}

尚未测试此功能,但此功能应适用于您。
在controller/product/category.php上尝试此操作,然后在$this->data['products']=array()之前

论第三方物流

if (isset($topCatImage)) {
   show this image
} else {
   show other image
}

在做类似的事情。希望它能帮助其他人,得到更多的代码:

目录\控制器\产品

$cat_array = explode ("_", $path);
$top_cat_id = $cat_array[0];            
$cat_Image = $this->model_catalog_category->getCatImage($top_cat_id);
if ($cat_Image) {
    //show this image
    $this->data['image'] = $cat_Image['image'];
} 
 <?php if ($image) { ?>
       <div class="image"><img src="<?php echo $image; ?>" alt="<?php echo $heading_title; ?>" /></div>
 <?php } else { ?>
       <div class="image"><img src="<?php echo $OTHERimage; ?>" alt="<?php echo $heading_title; ?>" /></div> 
 <?php } ?>
catalog\model\catalog

 public function getCatImage($category_id) {

    $query = $this->db->query("SELECT image FROM " . DB_PREFIX . 
    "category AS cat LEFT JOIN category AS cats ON cats.parent_id = cat.category_id WHERE cat.parent_id =0 AND cat.category_id = '" . (int)$category_id . "'");

    return $query->row;

}
catalog\view\theme\default\template\product

$cat_array = explode ("_", $path);
$top_cat_id = $cat_array[0];            
$cat_Image = $this->model_catalog_category->getCatImage($top_cat_id);
if ($cat_Image) {
    //show this image
    $this->data['image'] = $cat_Image['image'];
} 
 <?php if ($image) { ?>
       <div class="image"><img src="<?php echo $image; ?>" alt="<?php echo $heading_title; ?>" /></div>
 <?php } else { ?>
       <div class="image"><img src="<?php echo $OTHERimage; ?>" alt="<?php echo $heading_title; ?>" /></div> 
 <?php } ?>

“alt=”“/>
“alt=”“/>

正在做类似的事情。希望它能帮助其他人,得到更多的代码:

目录\控制器\产品

$cat_array = explode ("_", $path);
$top_cat_id = $cat_array[0];            
$cat_Image = $this->model_catalog_category->getCatImage($top_cat_id);
if ($cat_Image) {
    //show this image
    $this->data['image'] = $cat_Image['image'];
} 
 <?php if ($image) { ?>
       <div class="image"><img src="<?php echo $image; ?>" alt="<?php echo $heading_title; ?>" /></div>
 <?php } else { ?>
       <div class="image"><img src="<?php echo $OTHERimage; ?>" alt="<?php echo $heading_title; ?>" /></div> 
 <?php } ?>
catalog\model\catalog

 public function getCatImage($category_id) {

    $query = $this->db->query("SELECT image FROM " . DB_PREFIX . 
    "category AS cat LEFT JOIN category AS cats ON cats.parent_id = cat.category_id WHERE cat.parent_id =0 AND cat.category_id = '" . (int)$category_id . "'");

    return $query->row;

}
catalog\view\theme\default\template\product

$cat_array = explode ("_", $path);
$top_cat_id = $cat_array[0];            
$cat_Image = $this->model_catalog_category->getCatImage($top_cat_id);
if ($cat_Image) {
    //show this image
    $this->data['image'] = $cat_Image['image'];
} 
 <?php if ($image) { ?>
       <div class="image"><img src="<?php echo $image; ?>" alt="<?php echo $heading_title; ?>" /></div>
 <?php } else { ?>
       <div class="image"><img src="<?php echo $OTHERimage; ?>" alt="<?php echo $heading_title; ?>" /></div> 
 <?php } ?>

“alt=”“/>
“alt=”“/>

您能再解释一下吗?你到底想做什么?当你改变标签时,你有一个风格问题。有些东西出了问题。请转到你的主页并检查一下,你能再解释一下吗?你到底想做什么?当你改变标签的时候,你有一个风格问题。有些地方出了问题。请转到你的主页并检查一下