使类别图像成为链接

时间:2014-06-19 19:33:48

标签: magento

我正在尝试将所有类别图像转换为链接。几年前我发现了SheetGeekExcelGeeks的答案,但我不知道如何填写我的类别图像:

非常感谢任何帮助

Making Category Image a link是原始问题和答案的链接

 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');
    }

1 个答案:

答案 0 :(得分:0)

你可以通过其他方式创建..

只需编写html&amp;的代码CSS然后创建静态块

并以静态集团过去。

现在从headr文件调用静态块..