Php 将产品说明显示为类别列表说明-OpenCart
可能重复:Php 将产品说明显示为类别列表说明-OpenCart,php,opencart,Php,Opencart,可能重复: 我有下面一行代码从数据库中提取描述 我试图做的是在描述中添加,这样它就不会显示为一个长数据字符串 mb_substr(strip_标记(html_实体解码($result['description'],ENT_引号,'UTF-8')),01100)。” 当前: $this->data['products'][] = array( 'product_id' => $result['product_id'],
我有下面一行代码从数据库中提取描述 我试图做的是在描述中添加
,这样它就不会显示为一个长数据字符串
mb_substr(strip_标记(html_实体解码($result['description'],ENT_引号,'UTF-8')),01100)。”代码>
当前:
$this->data['products'][] = array(
'product_id' => $result['product_id'],
'thumb' => $image,
'name' => $result['name'],
'description' => mb_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, 100) . '..',
'price' => $price,
'special' => $special,
'tax' => $tax,
'rating' => $result['rating'],
'reviews' => sprintf($this->language->get('text_reviews'), (int)$result['reviews']),
'href' => $this->url->link('product/product', 'path=' . $this->request->get['path'] . '&product_id=' . $result['product_id'])
);
'description' => mb_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, 100) . '..'
'description' => strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8'),'<p>'),
数据。数据。数据。数据。数据。数据
必填项:
$this->data['products'][] = array(
'product_id' => $result['product_id'],
'thumb' => $image,
'name' => $result['name'],
'description' => mb_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, 100) . '..',
'price' => $price,
'special' => $special,
'tax' => $tax,
'rating' => $result['rating'],
'reviews' => sprintf($this->language->get('text_reviews'), (int)$result['reviews']),
'href' => $this->url->link('product/product', 'path=' . $this->request->get['path'] . '&product_id=' . $result['product_id'])
);
'description' => mb_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, 100) . '..'
'description' => strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8'),'<p>'),
数据数据
数据数据
数据数据
完整代码:
$this->data['products'][] = array(
'product_id' => $result['product_id'],
'thumb' => $image,
'name' => $result['name'],
'description' => mb_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, 100) . '..',
'price' => $price,
'special' => $special,
'tax' => $tax,
'rating' => $result['rating'],
'reviews' => sprintf($this->language->get('text_reviews'), (int)$result['reviews']),
'href' => $this->url->link('product/product', 'path=' . $this->request->get['path'] . '&product_id=' . $result['product_id'])
);
'description' => mb_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, 100) . '..'
'description' => strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8'),'<p>'),
使用例如
使用例如
我已通过以下操作解决了此问题:
编辑->catelog/view/theme/default/template/product/product.tpl
在上述.tpl文档中,我在数组中调整了第196行:
发件人:
$this->data['products'][] = array(
'product_id' => $result['product_id'],
'thumb' => $image,
'name' => $result['name'],
'description' => mb_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, 100) . '..',
'price' => $price,
'special' => $special,
'tax' => $tax,
'rating' => $result['rating'],
'reviews' => sprintf($this->language->get('text_reviews'), (int)$result['reviews']),
'href' => $this->url->link('product/product', 'path=' . $this->request->get['path'] . '&product_id=' . $result['product_id'])
);
'description' => mb_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, 100) . '..'
'description' => strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8'),'<p>'),
至:
$this->data['products'][] = array(
'product_id' => $result['product_id'],
'thumb' => $image,
'name' => $result['name'],
'description' => mb_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, 100) . '..',
'price' => $price,
'special' => $special,
'tax' => $tax,
'rating' => $result['rating'],
'reviews' => sprintf($this->language->get('text_reviews'), (int)$result['reviews']),
'href' => $this->url->link('product/product', 'path=' . $this->request->get['path'] . '&product_id=' . $result['product_id'])
);
'description' => mb_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, 100) . '..'
'description' => strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8'),'<p>'),
'description'=>条带标签(html实体解码($result['description'],ENT_引号,'UTF-8'),“”),
我已通过执行以下操作解决了此问题:
编辑->catelog/view/theme/default/template/product/product.tpl
在上述.tpl文档中,我在数组中调整了第196行:
发件人:
$this->data['products'][] = array(
'product_id' => $result['product_id'],
'thumb' => $image,
'name' => $result['name'],
'description' => mb_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, 100) . '..',
'price' => $price,
'special' => $special,
'tax' => $tax,
'rating' => $result['rating'],
'reviews' => sprintf($this->language->get('text_reviews'), (int)$result['reviews']),
'href' => $this->url->link('product/product', 'path=' . $this->request->get['path'] . '&product_id=' . $result['product_id'])
);
'description' => mb_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, 100) . '..'
'description' => strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8'),'<p>'),
至:
$this->data['products'][] = array(
'product_id' => $result['product_id'],
'thumb' => $image,
'name' => $result['name'],
'description' => mb_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, 100) . '..',
'price' => $price,
'special' => $special,
'tax' => $tax,
'rating' => $result['rating'],
'reviews' => sprintf($this->language->get('text_reviews'), (int)$result['reviews']),
'href' => $this->url->link('product/product', 'path=' . $this->request->get['path'] . '&product_id=' . $result['product_id'])
);
'description' => mb_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, 100) . '..'
'description' => strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8'),'<p>'),
'description'=>条带标签(html实体解码($result['description'],ENT_引号,'UTF-8'),“”),
谢谢,我已经放置了完整的代码,我必须将其从当前数组中拆分吗?谢谢,我已经放置了完整的代码,我必须将其从当前数组中拆分吗?我应该在上面的mb_substr字符串中的何处实现上述内容?在字符串上,例如mb_substr(文字包装(strip_标记(html_entity_decode)($result['description')),引用“UTF-8”),10,
,true),01100)。”代码>嘿,它似乎无法正常工作:(10太小了,将数字增加到每行所需的字符数,10只是一个示例;)我有,但每行的字符数都不相同。我应该在上面的mb_substr字符串中实现上面的内容吗?在字符串上,例如mb_substr(wordwrap(strip_标记(html_entity_decode($result['description'],ENT_QUOTES,'UTF-8')),10,
,true),0,100)。“…”
嘿,它似乎无法正常工作:(10太小了,将数字增加到每行所需的字符数,10只是一个示例;)我有,但每行的字符数都不相同