【问题标题】:adding category image to the category page in magento将类别图像添加到 magento 中的类别页面
【发布时间】:2016-09-09 06:02:10
【问题描述】:

我正在尝试在我的类别登录页面顶部添加类别图片。 我正在使用豪华主题和magento 1.9版本

到目前为止我做了什么: 我已经在管理员 -> 管理类别 -> 我的类别 -> 在一般信息选项卡中添加了图像我添加了图像

接下来我尝试更改page/html/Breadcrumbs.phtml 中的代码,但没有成功

这是page/html/Breadcrumbs.phtml中的默认代码

<?php if($crumbs && is_array($crumbs)): ?>

    <?php
        $bg_image = $this->getLayout()->createBlock('cms/block')->setBlockId('luxury-background-breadcrumbs')->toHtml();
        preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $bg_image, $matches);     
    ?>
<div class="breadcrumbs" <?php if($matches[1][0] !=''): ?>style="background-image:url(<?php echo $matches[1][0]?>);"<?php endif;?>>
</div>

帮助如何将图像显示到页面的顶部(标题)。

有什么方法可以只获取类别的图像吗?

【问题讨论】:

  • 你用谷歌搜索了吗?
  • Inside Manage Categories 将其添加到 Image 属性中。默认情况下,它应该作为横幅出现在您的类别登录页面中。
  • 是的,我用谷歌搜索了,我确实将它添加到了图像属性中,但它没有显示在类别登录页面中
  • 你能告诉我们类别视图页面代码..而不是列表页面

标签: php magento magento-1.9


【解决方案1】:
Go to your catalog->category->view.phtml page search for $_imagHtml if not found use this below code in your file 
<?php $_imgHtml   = '';
    if ($_imgUrl = $_category->getImageUrl()) {
        $_imgHtml = '<p class="category-image"><img src="'.$_imgUrl.'" alt="'.$this->escapeHtml($_category->getName()).'" title="'.$this->escapeHtml($_category->getName()).'" /></p>';
        $_imgHtml = $_helper->categoryAttribute($_category, $_imgHtml, 'image');
    }?>
<?php if($_imgUrl): ?>
    <?php echo $_imgHtml ?>
<?php endif; ?>

【讨论】:

    【解决方案2】:

    实现此目的的一种无需代码的方式,可以完全从 Magento 安装的管理员端完成。 对于您要为其加载图像的每个类别,创建一个静态 cms 块 (cms->静态块->添加新块)并将所需类别图像的html图像标记放在其中。给它一个好听的名字,比如(为了举例)Category23_Image_block。

    现在编辑您的类别的属性,然后转到设计选项卡。将“显示模式”设置为“静态块和产品”,然后从“CMS 块”下拉列表中选择新的静态块。

    现在应该将包含所需图像的块直接放在类别登录页面的顶部。

    【讨论】:

      【解决方案3】:

      谷歌这个 magento 在哪里存储类别图像?

      public_html/媒体/目录

      确定图像的存储位置后,转到 Cpanel 并找到它们

      查看权限,您可能会看到权限设置为 640

      将权限改为644并保存

      刷新您的前端页面,图像应该在那里

      【讨论】:

      • 不要添加 cmets 作为答案
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多