在Magento中为单个页面插入css引用的最佳方法
在Magento中尝试将custom.css文件的引用添加到customer dashboard页面时没有遇到任何问题。这让我想用海豹突击队的方式射中Magento的眼睛 根据文档,插入到中的customer.xml中的以下任一项都应该有效:在Magento中为单个页面插入css引用的最佳方法,css,xml,magento,block,Css,Xml,Magento,Block,在Magento中尝试将custom.css文件的引用添加到customer dashboard页面时没有遇到任何问题。这让我想用海豹突击队的方式射中Magento的眼睛 根据文档,插入到中的customer.xml中的以下任一项都应该有效: <reference name="customer_account_dashboard"> <action method="addCss"><link>dashboardfix.css</link>&
<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>
dashboardfix.css
css/dashboardfix.css
在该块之前插入时:
<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>
它无声地失败(没有错误,就好像根本没有处理过一样)
在块之后插入时,我得到一个“无效方法Mage\u Customer\u block\u Account\u Dashboard::addCss(Array([0]=>css/dashboardfix.css))错误
dashboardfix.css与我的其他资产一起位于skinname/css文件夹中
有什么想法吗?代码中有一个小的语法错误-请参阅下面更正的代码 此外,要使其工作,您需要将文件放置在与styles.css(或box.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>
客户我的帐户(所有页面)
一切都会很好。谢谢!成功了。在我看到您的回复之前,我已经在.phtml文件中使用$headBlock=$this->getLayout()->getBlock('head');$headBlock->getSkinUrl('css/dashboardfix.css')实现了;不过,您的解决方案很优雅。我也尝试过类似的方法,但使用blocktype=page\u head,而不是reference=head。再次感谢!