Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
If statement opencart href链接取决于类别\u id_If Statement_Opencart - Fatal编程技术网

If statement opencart href链接取决于类别\u id

If statement opencart href链接取决于类别\u id,if-statement,opencart,If Statement,Opencart,我是Opencart的新手,我需要一个If-then语句,它将加载一个不同的.tpl页面,具体取决于category\u id 我试过了,但表现出了错误 分析错误:语法错误,意外的“if”T\u if,第28行的D:\xampp\htdocs\ramesh\lmw\catalog\controller\product\sub\u category.php中应为 这是我的密码 sub_category.php 试试这个 foreach ($category_info as $result) {

我是Opencart的新手,我需要一个If-then语句,它将加载一个不同的.tpl页面,具体取决于category\u id

我试过了,但表现出了错误

分析错误:语法错误,意外的“if”T\u if,第28行的D:\xampp\htdocs\ramesh\lmw\catalog\controller\product\sub\u category.php中应为

这是我的密码

sub_category.php

试试这个

foreach ($category_info as $result) {
        $data['categories'][] = array(
            'name' => $result['name'],
            'parent_id' => $result['parent_id'],
            'thumb' => $this->model_tool_image->resize($result['image'], $this->config->get('config_image_category_width'), $this->config->get('config_image_category_height')),
            'description' => utf8_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, $this->config->get('config_product_description_length')) . '..',
            #'href' => $this->url->link('product/filter', '&category_id=' . $result['category_id'])
            #'href' => $this->url->link('product/sub_category')
            if($result['category_id'] == 24)
            {
            'href' => $this->url->link('product/transmission', 'sub_category_id='.$result['parent_id'].'&category_id=' . $result['category_id'])
            }
            else
            {
                'href' => $this->url->link('product/filter', 'sub_category_id='.$result['parent_id'].'&category_id=' . $result['category_id'])
            };
        );
    }

看起来你错过了一次机会;在if语句之后。另外,您应该使用/*not

进行注释,感谢您重播我Alexander Funari,但是在第41行的D:\xampp\htdocs\ramesh\catalog\controller\product\sub_category.php中出现了诸如语法错误、意外的“if'T_-if”等错误
    foreach ($category_info as $result) {
 if($result['category_id']==24)
 {
    $link1 = $this->url->link('product/transmission', 'sub_category_id='.$result['parent_id'].'&category_id=' . $result['category_id']);
 }
else
{
    $link1 = $this->url->link($_SERVER["REQUEST_URI"]);
}
$data['categories'][] = array(
    'name' => $result['name'],
    'parent_id' => $result['parent_id'],
    'thumb' => $this->model_tool_image->resize($result['image'], $this->config->get('config_image_category_width'), $this->config->get('config_image_category_height')),
    'description' => utf8_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, $this->config->get('config_product_description_length')) . '..',
    /*'href' => $this->url->link('product/filter', '&category_id=' . $result['category_id'])
    'href' => $this->url->link('product/sub_category')
    'href' => $this->url->link('product/transmission', 'sub_category_id='.$result['parent_id'].'&category_id=' . $result['category_id'])*/
    'href' => $link1
);
    foreach ($category_info as $result) {
 if($result['category_id']==24)
 {
    $link1 = $this->url->link('product/transmission', 'sub_category_id='.$result['parent_id'].'&category_id=' . $result['category_id']);
 }
else
{
    $link1 = $this->url->link($_SERVER["REQUEST_URI"]);
}
$data['categories'][] = array(
    'name' => $result['name'],
    'parent_id' => $result['parent_id'],
    'thumb' => $this->model_tool_image->resize($result['image'], $this->config->get('config_image_category_width'), $this->config->get('config_image_category_height')),
    'description' => utf8_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, $this->config->get('config_product_description_length')) . '..',
    /*'href' => $this->url->link('product/filter', '&category_id=' . $result['category_id'])
    'href' => $this->url->link('product/sub_category')
    'href' => $this->url->link('product/transmission', 'sub_category_id='.$result['parent_id'].'&category_id=' . $result['category_id'])*/
    'href' => $link1
);