是否可以将您在常规信息选项卡中设置的主类别图像制作为链接?将类别图像链接到
它呈现出来的:
<img src="http://www.example.com/media/catalog/category/example.jpg" alt="Example" title="Example" class="category-image" />
也许有一些扩展做到这一点?它只是不适合有一个不可点击的主要横幅...
是否可以将您在常规信息选项卡中设置的主类别图像制作为链接?将类别图像链接到
它呈现出来的:
<img src="http://www.example.com/media/catalog/category/example.jpg" alt="Example" title="Example" class="category-image" />
也许有一些扩展做到这一点?它只是不适合有一个不可点击的主要横幅...
你想链接到同一类别或其他网页?你可以试试这个技巧...
类别的图像都是通过调用
<p><?php echo $_imgHtml?></p>
模板\目录\类\ view.phtml文件
加载。
您可以进行以下更改并硬编码链接或使用动态链接。
<p><a href="#"><?php echo $_imgHtml?></a></p>
如果要将其链接到当前类别,可以将当前类别URL函数分配给$变量并将其用作链接。
$_category->getUrl()
如果您有特定要求,请在答案上留言。
没有一套答案,但这里是我们如何能够做到在Magento 1.7.0.2:
在文件app /设计/前端/基/默认/模板/目录/分类/ view.phtml有这些行添加图像:
if ($_imgUrl = $_category->getImageUrl()) {
$_imgHtml = '<p class="category-image"><img src="'.$_imgUrl.'" alt="'.$this- >htmlEscape($_category->getName()).'" title="'.$this->htmlEscape($_category->getName()).'" /> </p>';
$_imgHtml = $_helper->categoryAttribute($_category, $_imgHtml, 'image');
}
这基本上说:如果有图像 - 创建必要的HTML来显示它。
您可以重新创建这些相同的线,并添加一个if语句:
if ($_imgUrl = $_category->getImageUrl()) {
//Add this, which reads: if the following text exists in the file name of the category image then create html with a link for that specific text
if(substr($_imgUrl,-20)=="some-systematic-identification-text"){
$_imgHtml = '<p class="category-image"><a href="http://www.MY_SITE_URL.com" target="_blank"><img src="'.$_imgUrl.'" alt="'.$this->htmlEscape($_category->getName()).'" title="'.$this->htmlEscape($_category->getName()).'" /></a></p>';
}
//Add this to check for more text
else if(substr($_imgUrl,-20)=="some-OTHER-systematic-identification-text"){
$_imgHtml = '<p class="category-image"><a href="http://www.MY_SITE_URL.com" target="_blank"><img src="'.$_imgUrl.'" alt="'.$this->htmlEscape($_category->getName()).'" title="'.$this->htmlEscape($_category->getName()).'" /></a></p>';
}
//Otherwise - just add the standard html that was there before we made changes
else{$_imgHtml = '<p class="category-image"><img src="'.$_imgUrl.'" alt="'.$this->htmlEscape($_category->getName()).'" title="'.$this->htmlEscape($_category->getName()).'" /></p>';}
//Part of if-category image - if statement
$_imgHtml = $_helper->categoryAttribute($_category, $_imgHtml, 'image');
}
您可以复制和粘贴这些线在4我把这个帖子顶,然后根据需要修改,以确定何时您的文件名称已显示为类别图像,并创建点击时弹出的相应链接。
假设你想要子类图像和那个类别的产品,那么你可以使用下面的代码。
<a href="<?php echo $subcat->getUrlPath();?>"><img src="<?php echo Mage::getBaseUrl()."media/catalog/category/".$subcat->getThumbnail() ?>"/></a>
它应该链接到什么? – 2009-11-17 14:49:37