2011-07-13 15 views
1

嘗試將對custom.css文件的引用添加到Magento中的客戶儀表板頁面時沒有任何運氣。這讓我想要拍攝Magento的眼睛,海軍海豹風格。爲Magento中的單個頁面插入css引用的最佳方法

根據該文檔,以下任一插入customer.xml在應該工作的:

<reference name="customer_account_dashboard"> 
    <action method="addCss"><link>dashboardfix.css</link></action> 
</reference> 

<reference name="customer_account_dashboard"> 
    <action method="addCss"><stylesheet>css/dashboardfix.css</stylesheet></action> 
</reference> 

當之前插入塊:

<reference name="my.account.wrapper"> 
    <block type="customer/account_dashboard" name="customer_account_dashboard" template="customer/account/dashboard.phtml"> 
     <block type="customer/account_dashboard_hello" name="customer_account_dashboard_hello" as="hello" template="customer/account/dashboard/hello.phtml"/> 
     <block type="core/template" name="customer_account_dashboard_top" as="top" /> 
     <block type="customer/account_dashboard_info" name="customer_account_dashboard_info" as="info" template="customer/account/dashboard/info.phtml"/> 
     <block type="customer/account_dashboard_newsletter" name="customer_account_dashboard_newsletter" as="newsletter" template="customer/account/dashboard/newsletter.phtml"/> 
     <block type="clientname/account_dashboard_address" name="customer_account_dashboard_address" as="address" template="customer/account/dashboard/address.phtml"/> 
    </block> 
</reference> 

它靜靜地失敗(沒有錯誤,它好像根本沒有處理過)

當插入 th ë塊,我得到一個「無效方法Mage_Customer_Block_Account_Dashboard :: addCss(陣列([0] => CSS/dashboardfix.css))錯誤

dashboardfix.css與我的其他資產的skinname/css文件夾。

任何想法?

回答

2

您的代碼中存在一個小的語法錯誤 - 請參閱下面的更正的代碼。

此外,爲了這項工作,您需要將macguffin.css文件放置在與您的styles.css(或boxes.css)相同的css文件夾中,即您的主題的css文件夾。

您可能還想關閉css文件的緩存和合並,以確保其正常工作。

這裏是你如何有完整的塊:

<!-- 
Customer account pages, rendered for all tabs in dashboard 
--> 

<customer_account translate="label"> 
    <label>Customer My Account (All Pages)</label> 
    <!-- Mage_Customer --> 
    <reference name="head"> 
     <action method="addCss"><stylesheet>css/macguffin.css</stylesheet></action> 
    </reference> 
    <reference name="root"> 
     <action method="setTemplate"><template>page/2columns-left.phtml</template></action> 
    </reference> 
    <reference name="content"> 
     <block type="page/html_wrapper" name="my.account.wrapper" translate="label"> 
      <label>My Account Wrapper</label> 
      <action method="setElementClass"><value>my-account</value></action> 
     </block> 
    </reference> 

    <reference name="left"> 
     <block type="customer/account_navigation" name="customer_account_navigation" before="-" template="customer/account/navigation.phtml"> 
      <action method="addLink" translate="label" module="customer"><name>account</name><path>customer/account/</path><label>Account Dashboard</label></action> 
      <action method="addLink" translate="label" module="customer"><name>account_edit</name><path>customer/account/edit/</path><label>Account Information</label></action> 
      <action method="addLink" translate="label" module="customer"><name>address_book</name><path>customer/address/</path><label>Address Book</label></action> 
     </block> 
     <remove name="tags_popular"/> 

    </reference> 
</customer_account> 

只要記住,只要你的CSS文件名爲macguffin.css它都制定得很好。

+0

謝謝!這工作。在我看到您的回覆之前,我已經使用$ headBlock = $ this-> getLayout() - > getBlock('head')在.phtml文件中處理它。 $ headBlock-> getSkinUrl( 'CSS/dashboardfix.css');雖然你的解決方案是優雅的。我曾試過類似的東西,但是blocktype = page_head,而不是reference = head。再次感謝! – ScottyDont

相關問題