【发布时间】:2010-12-16 03:38:57
【问题描述】:
我正在尽我最大的努力按照他们希望的方式编辑 Magento 设计(使用 local.xml 而不是编辑 page.xml),但是这个系统非常可怕和复杂,事实证明它非常棘手这样做。
我现在遇到的问题是我似乎无法将“top.links”块移动到标题中的另一个块中。目前在 page.xml 中,此块位于标头块中。我已经尝试了 local.xml 中的所有内容以使其正常工作,我尝试了以下编辑。
从标题中删除 top.links,添加到“Hud”块内。
<layout version="0.1.0">
<default>
<!-- Here is where we edit the header block -->
<reference name="header">
<remove name="top.links" />
<remove name="top.search" />
<!-- This is the block that holds the HUD -->
<block type="page/html" name="hud" as="hud" template="page/html/hud.phtml">
<block type="page/template_links" name="top.links" as="topLinks" />
</block>
</reference>
</default>
</layout>
请注意,链接应位于棕色框内(这是 HUD 块)。
不从标题中删除 top.links 块,而是添加到 Hud 块
<layout version="0.1.0">
<default>
<!-- Here is where we edit the header block -->
<reference name="header">
<remove name="top.search" />
<!-- This is the block that holds the HUD -->
<block type="page/html" name="hud" as="hud" template="page/html/hud.phtml">
<block type="page/template_links" name="top.links" as="topLinks" />
</block>
</reference>
</default>
</layout>
根据 top.links 的代码创建了新的 Links 模板,并在 HUD 的块中引用如下。
<layout version="0.1.0">
<default>
<!-- Here is where we edit the header block -->
<reference name="header">
<remove name="top.links" />
<remove name="top.search" />
<!-- This is the block that holds the HUD -->
<block type="page/html" name="hud" as="hud" template="page/html/hud.phtml">
<block type="page/template_links" name="hud.links" as="hudLinks" template="page/template/hudLinks.phtml"/>
</block>
</reference>
</default>
</layout>
下面是hud.phtml
<!-- hud.phtml -->
<div id="hud">
<h3>Welcome</h3>
<?php echo $this->getChildHtml('hudLinks') ?>
<?php echo $this->getChildHtml('top.search') ?>
</div>
这带来了最有趣的结果。我可以看到找到了模板,但没有出现任何内容。
我真的对此一无所知。我在这里做错了什么吗?值得一提的是,这里是我用于 hudLinks.phtml 和 top.links 模板的代码。
<?php $_links = $this->getLinks(); ?>
<?php if(count($_links)>0): ?>
<ul class="links"<?php if($this->getName()): ?> id="<?php echo $this->getName() ?>"<?php endif;?>>
<?php foreach($_links as $_link): ?>
<li<?php if($_link->getIsFirst()||$_link->getIsLast()): ?> class="<?php if($_link->getIsFirst()): ?>first<?php endif; ?><?php if($_link->getIsLast()): ?> last<?php endif; ?>"<?php endif; ?> <?php echo $_link->getLiParams() ?>><?php echo $_link->getBeforeText() ?><a href="<?php echo $_link->getUrl() ?>" title="<?php echo $_link->getTitle() ?>" <?php echo $_link->getAParams() ?>><?php echo $_link->getLabel() ?></a><?php echo $_link->getAfterText() ?></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
【问题讨论】:
-
如果
page.xml是您自己的主题,我认为编辑没有问题。 -
我开始的主题基本上使用了Magento基础中的page.xml文件。我尝试在我自己的主题布局文件夹中使用 page.xml 文件来覆盖它,但它似乎不起作用。感谢您的回复。