2012-03-01 54 views
1

最近我已經開始與Magento 1.6.1合作,爲我在本地的一家電子商務公司擔任新職位。我有以前的經驗,但主要是使用Wordpress。使用Magento佈局

雖然我「知道」Magento,可以圍繞它的工作方式包裹我的頭,當然還有障礙。幸運的是,我有一個足夠好的老闆,讓我在代碼中弄髒自己的雙手,並且每天都會越來越多地學習。

最近雖然,佈局一直是我的新障礙。麻煩的是我在代碼中工作,這個代碼是由別人完成的,或者是別人對代碼的修改。我不是第一個網站管理員...

我很難移動「bottom.phtml」塊,所以它呈現在「media.phtml」(產品圖像/縮略圖呈現處)下方。代碼如下:

<catalog_product_view translate="label"> 
    <label>Catalog Product View (Any)</label> 
    <!-- Mage_Catalog --> 
    <reference name="root"> 
     <action method="setTemplate"><template>page/1column.phtml</template></action> 
    </reference> 
    <reference name="head"> 
     <action method="addJs"><script>varien/product.js</script></action> 

     <action method="addJs"><script>virtualpaginate.js</script></action> 

     <action method="addItem"><type>js_css</type><name>calendar/calendar-win2k-1.css</name><params/><!--<if/><condition>can_load_calendar_js</condition>--></action> 
     <action method="addItem"><type>js</type><name>calendar/calendar.js</name><!--<params/><if/><condition>can_load_calendar_js</condition>--></action> 
     <action method="addItem"><type>js</type><name>calendar/calendar-setup.js</name><!--<params/><if/><condition>can_load_calendar_js</condition>--></action> 

    </reference> 
    <reference name="content"> 
     <block type="catalog/product_view" name="product.info" template="catalog/product/view.phtml"> 
      <!-- 
      <action method="addReviewSummaryTemplate"><type>default</type><template>review/helper/summary.phtml</template></action> 
      <action method="addReviewSummaryTemplate"><type>short</type><template>review/helper/summary_short.phtml</template></action> 
      <action method="addReviewSummaryTemplate"><type>...</type><template>...</template></action> 
      --> 
      <block type="catalog/product_view_media" name="product.info.media" as="media" template="catalog/product/view/media.phtml"/> 
      <block type="core/text_list" name="alert.urls" as="alert_urls" translate="label"> 
       <label>Alert Urls</label> 
      </block> 

      <action method="setTierPriceTemplate"><template>catalog/product/view/tierprices.phtml</template></action> 
      <block type="catalog/product_list_related" name="catalog.product.related" as="related" template="catalog/product/list/related.phtml"/> 
      <block type="catalog/product_list_upsell" name="product.info.upsell" as="upsell_products" template="catalog/product/list/upsell.phtml"> 
       <action method="setColumnCount"><columns>4</columns></action> 
       <action method="setItemLimit"><type>upsell</type><limit>4</limit></action> 
      </block> 

      <block type="catalog/product_view_additional" name="product.info.additional" as="product_additional_data" /> 
      <block type="catalog/product_view_description" name="product.description" as="description" template="catalog/product/view/description.phtml"/> 
      <block type="catalog/product_view_attributes" name="product.attributes" as="additional" template="catalog/product/view/attributes.phtml"/> 
      <block type="catalog/product_view" name="product.info.addto" as="addto" template="catalog/product/view/addto.phtml"/> 
      <block type="catalog/product_view" name="product.info.addtocart" as="addtocart" template="catalog/product/view/addtocart.phtml"/> 

      <block type="catalog/product_view" name="product.info.options.wrapper" as="product_options_wrapper" template="catalog/product/view/options/wrapper.phtml" translate="label"> 
       <label>Info Column Options Wrapper</label> 
       <block type="core/template" name="options_js" template="catalog/product/view/options/js.phtml"/> 
       <block type="catalog/product_view_options" name="product.info.options" as="product_options" template="catalog/product/view/options.phtml"> 
        <action method="addOptionRenderer"><type>text</type><block>catalog/product_view_options_type_text</block><template>catalog/product/view/options/type/text.phtml</template></action> 
        <action method="addOptionRenderer"><type>file</type><block>catalog/product_view_options_type_file</block><template>catalog/product/view/options/type/file.phtml</template></action> 
        <action method="addOptionRenderer"><type>select</type><block>catalog/product_view_options_type_select</block><template>catalog/product/view/options/type/select.phtml</template></action> 
        <action method="addOptionRenderer"><type>date</type><block>catalog/product_view_options_type_date</block><template>catalog/product/view/options/type/date.phtml</template></action> 
      </block> 
        <block type="core/html_calendar" name="html_calendar" as="html_calendar" template="page/js/calendar.phtml"/> 
       </block> 
      <block type="catalog/product_view" name="product.info.options.wrapper.bottom" as="product_options_wrapper_bottom" template="catalog/product/view/options/wrapper/bottom.phtml" translate="label"> 
       <label>Bottom Block Options Wrapper</label> 
       <action method="insert"><block>product.tierprices</block></action> 
       <block type="catalog/product_view" name="product.clone_prices" as="prices" template="catalog/product/view/price_clone.phtml"/> 
       <action method="append"><block>product.info.addtocart</block></action> 
      </block> 

      <block type="core/template_facade" name="product.info.container1" as="container1"> 
       <action method="setDataByKey"><key>alias_in_layout</key><value>container1</value></action> 
       <action method="setDataByKeyFromRegistry"><key>options_container</key><key_in_registry>product</key_in_registry></action> 
       <action method="append"><block>product.info.options.wrapper</block></action> 
       <action method="append"><block>product.info.options.wrapper.bottom</block></action> 
      </block> 
      <block type="core/template_facade" name="product.info.container2" as="container2"> 
       <action method="setDataByKey"><key>alias_in_layout</key><value>container2</value></action> 
       <action method="setDataByKeyFromRegistry"><key>options_container</key><key_in_registry>product</key_in_registry></action> 
       <action method="append"><block>product.info.options.wrapper</block></action> 
       <action method="append"><block>product.info.options.wrapper.bottom</block></action> 
      </block> 
      <action method="unsetCallChild"><child>container1</child><call>ifEquals</call><if>0</if><key>alias_in_layout</key><key>options_container</key></action> 
      <action method="unsetCallChild"><child>container2</child><call>ifEquals</call><if>0</if><key>alias_in_layout</key><key>options_container</key></action> 
     </block> 
    </reference> 
    <reference name="right"> 
     <block type="catalog/product_list_related" name="catalog.product.related" before="-" template="catalog/product/list/related.phtml"/> 
    </reference> 
</catalog_product_view> 

現在,正如我所說,我正在學習Magento的我走了,在一定程度上,並與我的WordPress更換主題皮膚知識,它肯定給了我一個優勢。但是,試圖對此進行解碼已被證明是一個艱難的障礙。也許我正在分析它,但是,我不能在這裏把我的頭圍繞幾件事情:1)它是如何知道將「media.phtml」左側浮動以及產品選項和「bottom.phtml」放在對? 2)我怎樣才能從選項中分離出「bottom.phtml」,這樣我就可以將它移動到「media.phtml」(產品圖片)下面,然後開始設計樣式?

我愛Magento,但男人是一個粗糙的拿起。

謝謝任何​​能夠擺脫任何光線或提供堅實資源的人!我找到的所有教程,資源都非常棒,但是處理全新的安裝,所以沒有太多的代碼。有了這個,我正在挖掘別人正在努力的代碼,誠實地說......這對我所知道的所有人來說都是非常糟糕的!

再次感謝!

回答

5

XML部分大多隻是使某些塊可用於模板文件的使用。 (當然也有例外,每一個規則,並在core/text_list塊或模板調用$this->getChildHtml('')的XML的順序並生效的情況下)

template/catalog/product/view.phtml看一看,你會看到許多HTML位和線...

<?php echo $this->getChildHtml('media') ?> 

...這是塊如何定位。現在bottom.phtml所使用的product_options_wrapper_bottom但該塊不能直接使用,它被添加到container1container2塊被這樣的輸出:

<?php if ($_product->isSaleable() && $this->hasOptions()):?> 
    <?php echo $this->getChildChildHtml('container1', '', true, true) ?> 
<?php endif;?> 

所有你需要做的是編輯catalog/product/view.phtml做到位是下跌的低頁。當然,不要直接編輯基本模板,而是將該文件複製到網站主題中的等效路徑。

產品視圖頁面可能是默認Magento安裝中最複雜的,它是開始您的位置的好地方。也許更好的開始是Alan Storm的No Frills Magento Layout。我可能不會是唯一的推薦它。