gpt4 book ai didi

php - Magento 1.9 在页脚显示最新产品

转载 作者:行者123 更新时间:2023-11-28 09:14:38 24 4
gpt4 key购买 nike

编辑:事实证明,下面的解决方案实际上是正确的。事实证明,我的 vagrant box 没有安装 php5-gd,因此 magento 无法执行图像操作,但 PHP 没有显示未安装的错误。所以确保你安装了 php5-gd :P

美好的一天!

我目前正在开发一个基于 Magento 1.9 的电子商务网站,我基本上是边做边学。我目前正在采用静态设计并将其转化为 Magento 主题。

我试图在商店的页脚区域显示商店中 6 种最新产品的图片(带链接),但我发现的教程和问题对我不起作用。

我基本上是从静态模板中取出我的页脚并将其粘贴到我的主题 footer.phtml 文件中。设计要求在 html 中像这样显示六个图像(如果这样有意义吗?)

<div class="medium-6 large-3 columns newlyAdded">
<div class="footerHat"></div>
<h3> Newly Added</h3>
<div class="row">
<ul class="small-block-grid-3">
<li><img src="./images/footer-image-1.jpg" alt="footer image"></li>
<li><img src="./images/footer-image-2.jpg" alt="footer image"></li>
<li><img src="./images/footer-image-3.jpg" alt="footer image"></li>
</ul>
</div>
<p></p>
<div class="row">
<ul class="small-block-grid-3">
<li><img src="./images/footer-image-4.jpg" alt="footer image"></li>
<li><img src="./images/footer-image-5.jpg" alt="footer image"></li>
<li><img src="./images/footer-image-6.jpg" alt="footer image"></li>
</ul>
</div>
</div>

我最初的想法是将其粘贴到一个静态 block 中,然后循环访问 Magento 模型中的一些内容,但我不确定这是否是最好的方法。

任何帮助将不胜感激,当然我会提供尽可能多的信息:)

谢谢

编辑:额外信息

page.xml 文件中与页脚相关的内容:

<block type="page/html_footer" name="footer" as="footer" template="page/html/footer.phtml">
<block type="page/html_wrapper" name="bottom.container" as="bottomContainer" translate="label">
<label>Page Footer</label>
<action method="setElementClass"><value>bottom-container</value></action>
</block>
<block type="page/switch" name="store_switcher" as="store_switcher" template="page/switch/stores.phtml"/>
<block type="page/template_links" name="footer_links" as="footer_links" template="page/template/links.phtml"/>
</block>

<block type="core/text_list" name="before_body_end" as="before_body_end" translate="label">
<label>Page Bottom</label>
<block type="page/html_cookieNotice" name="global_cookie_notice" as ="global_cookie_notice" template="page/html/cookienotice.phtml" before="-" />
</block>

<reference name="footer">
<block type="catalog/product_new" name="home.catalog.product.new" alias="product_new" template="catalog/product/new.phtml">
<action method="setProductsCount"><count>4</count></action>
</block>
</reference>

footer.phtml 文件(默认 magento 版本)

<div class="footer-container">
<div class="footer">
<?php echo $this->getChildHtml() ?>
<p class="bugs"><?php echo $this->__('Help Us to Keep Magento Healthy') ?> - <a href="http://www.magentocommerce.com/bug-tracking" onclick="this.target='_blank'"><strong><?php echo $this->__('Report All Bugs') ?></strong></a> <?php echo $this->__('(ver. %s)', Mage::getVersion()) ?></p>
<address><?php echo $this->getCopyright() ?></address>
</div>
</div>

custom_page.xml:

<?xml version="1.0"?>
<layout>
<custom_layout translate="label">
<label>Custom layout</label>
<reference name="root">
<action method="setTemplate"><template>page/custom_layout.phtml</template></action>
<action method="setIsHandle"><applied>1</applied></action>
</reference>
</custom_layout>
</layout>

最佳答案

Magento 已经具备此功能,您可以使用以下代码在页脚/您想要显示的任何位置显示新产品

<reference name="footer">
<block type="catalog/product_new" name="home.catalog.product.new" alias="product_new" template="catalog/product/new.phtml" after="cms_page">
<action method="setProductsCount"><count>4</count></action>
</block>
</reference>

注意 我认为您已经遵循了 Magento 的主题化方式并拥有“引用页脚”,如果您愿意,您可以将 block 代码放入任何引用调用中,并可以直接在页脚中调用它.phtml.

如果您想设置布局样式,请在“app/design/frontend/{themepackage}/{themename} 中创建“app/design/frontend/base/default/template/catalog/product/new.phtml”的副本/template/catalog/product/new.phtml"并修改布局。

如有任何疑问,请随时发表评论!希望这对您有所帮助!

关于php - Magento 1.9 在页脚显示最新产品,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26340724/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com