Magentoデザインを(page.xmlを編集するのではなくlocal.xmlを使用して)編集するのが最善ですが、これはシステムはとても恐ろしく複雑ですが、これを行うことは非常に難しいことが分かります。Magentoのtop.links(topLinks)ブロックを移動できません
私が今問題にしているのは、「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のコードに基づいに添加し、この言及しません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 -->
<div id="hud">
<h3>Welcome</h3>
<?php echo $this->getChildHtml('hudLinks') ?>
<?php echo $this->getChildHtml('top.search') ?>
</div>
hud.phtmlです。テンプレートは見つかりましたが、何も表示されません。
私は本当にこれで無知です。私はここで何か完全に間違っているのですか?それが価値があるのは、ここで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'の編集には問題はありません。 – clockworkgeek
私が始めたテーマは、基本的にMagentoのベースにあるpage.xmlファイルを使用しています。私は自分のテーマのレイアウトフォルダ内でpage.xmlファイルを使用してこれを上書きしようとしましたが、うまくいかないようです。お返事をありがとうございます。 –