2013-06-19 77 views
0

我正在重新設計客戶端的頂級類別頁面,我希望通過使其具有動態性來面向未來的設計。爲了進一步說明,我希望每當客戶添加,編輯或刪除當前級別以下的類別時,都會在前端反映,而不需要編輯代碼。現在動態Magento頂級類別頁面

,我所遇到的話題,甚至堆棧論壇帖子一些博客文章: http://www.templatemonster.com/help/magento-listing-sub-categories-on-a-category-page.html how to display thumbnail from category using getThumbnailUrl() in Magento

然而,這些都處理不同的看法。該帖子還導致我: http://www.douglasradburn.co.uk/getting-category-thumbnail-images-with-magento/

我發現我需要添加拉圖像的功能(去Magento的方式)。但是,這是我需要的!這裏的最終目標是在類別的後端使用縮略圖,而不是圖像。按照預期,我們正在其他地方使用該映像。我還希望能夠從後端拉到前端的類別描述,目的是添加一些額外的信息,如鏈接,真實描述等。

如果有誰能幫助我?我經歷了上面的例子和鏈接,但是縮略圖圖像並沒有拉到前端,總體而言,我只是有些奇怪的行爲。任何提示將不勝感激,因爲我自己進一步研究。

謝謝!

回答

0

請嘗試以下代碼。我已經實現了同一本

<?php $category_path   = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA)."catalog/category/"; ?> 
<?php if (!Mage::registry('current_category')) return ?> 
<?php $_categories = $this->getCurrentChildCategories() ?> 
<?php $_count = is_array($_categories)?count($_categories):$_categories->count(); ?> 
<?php if($_count): ?> 
    <div class="static-page-listing static-page-listing1"> 
     <ul class="products-grid"> 
      <?php $num = 0; ?> 
      <?php foreach ($_categories as $_category): ?> 
       <?php if($_category->getIsActive()): 
       $num++; 
        $selImage  = "SELECT value FROM catalog_category_entity_varchar WHERE attribute_id = '126' AND entity_id = '".$_category->getId()."'"; 
        $catImage  = Mage::getSingleton('core/resource')->getConnection('core_read')->fetchOne($selImage); 
        if(!$catImage) $catImage = "no_image.jpg"; ?> 
        <li class="category-item <?php if($num%2==0) echo 'item-right'?>"> 
         <a href="<?php echo $this->getCategoryUrl($_category) ?>"> 
         <div style="float:left; width:100%;"> 
           <img src="<?php echo $category_path.$catImage?>"> 
         </div> 
         <div> 
          <h3><?php echo $this->htmlEscape($_category->getName()) ?></h3> 
          <h6 style = "color:red;">VIEW ALL</h6> 
         </div> 
         </a> 
        </li> 

       <?php endif; ?> 
       <?php endforeach ?> 
     </ul> 
    </div> 
<?php endif; ?> 
+0

這確實做了我想要的,但它仍然沒有拉類別的縮略圖...任何想法? – thatguycraig

+0

@thatguycraig它顯示了類別圖像。要顯示該類別的縮略圖圖像,您需要從「catalog_category_entity」表中找到'attribute_id'。 – Afsal

+0

我現在能夠拉動縮略圖,但是......我還需要拉動分類描述字段以沿着類別的縮略圖和標題...我怎樣才能將此添加到此@Afsal?謝謝!! – thatguycraig

0

新的更新:

下面的代碼工作:

<?php echo $cur_category->getDescription(); ?> 

但是,你需要確保檢查您的作用域!沒有意識到我的個人存儲範圍未被檢查以遵循「所有範圍」的默認設置,我解決了這個問題,上面的代碼在添加到「DESCRIPTION」區域後爲我工作!

謝謝堆棧!

以前的更新:

我現在有代碼的工作,我在網上找到的,它涉及到我加入一個函數來拉動類別縮略圖。有用!這裏是加價的模板:

<div class="category-products"> 
<ul class="products-grid"> 

     <?php 
      $_categories=$this->getCurrentChildCategories(); 

      if($_categories->count()): 
       $categorycount = 0; 

      foreach ($_categories as $_category): 
      if($_category->getIsActive()): 
       $cur_category=Mage::getModel('catalog/category')->load($_category->getId()); 
       $layer = Mage::getSingleton('catalog/layer'); 
       $layer->setCurrentCategory($cur_category); 
       $catName = $this->getCurrentCategory()->getName(); 

      if ($categorycount == 0){ 
       $class = "first"; 
      } 

      elseif ($categorycount == 3){ 
       $class = "last"; 
      } 

      else{ 
       $class = ""; 
      } 
     ?> 


    <li class="item <?=$class?>"> 
     <a href="<?php echo $cur_category->getURL() ?>" title="<?php echo $this->htmlEscape($cur_category->getName()) ?>"> 
      <img src="<?php echo $cur_category->getThumbnailUrl() ?>" width="100" alt="<?php echo $this->htmlEscape($cur_category->getName()) ?>" /> 
     </a> 

     <h2> 
      <a href="<?php echo $cur_category->getURL() ?>" title="<?php echo $this->htmlEscape($cur_category->getName()) ?>"> 
       <?php echo $this->htmlEscape($cur_category->getName()) ?> 
      </a> 
     </h2> 

     <p> 
      DESCRIPTION 
     </p> 
    </li> 

     <?php 
      endif; 
      if($categorycount == 3){ 
       $categorycount = 0; 

       echo "</ul>\n\n<ul class=\"products-grid\">"; 
      } 

      else{ 
       $categorycount++; 
      } 

      endforeach; 
      endif; 
     ?> 

</ul> 

現在,在那裏你看到「描述,」我想從後端拉動類別描述數據並將其輸出那裏。基本上,允許動態創建/修改頂級類別頁面。

我該如何拉動描述?我不是Magento的專家,也許我錯過了一些基本的東西,但我無法得到它的工作。

謝謝!