2010-12-15 6 views
1

Magento 디자인을 편집하는 대신 (예 : page.xml을 편집하는 대신 local.xml을 사용하여) Magento 디자인을 편집하는 것이 최선이지만 시스템이 너무 끔찍하고 뒤죽박죽이어서, 그렇게하는 것이 심각하게 까다로울 수 있습니다.Magento의 top.links (topLinks) 블록을 이동할 수 없습니다.

내가 지금 가지고있는 문제는 "top.links"블록을 헤더의 다른 블록으로 옮길 수 없다는 것입니다. 현재 page.xml의이 블록은 헤더 블록 안에 있습니다. 이 기능을 사용하려면 local.xml에서 모든 것을 시도했지만 다음 편집을 시도했습니다.

헤더에서 top.links를 제거하고 "Hud"블록을 추가하십시오. 링크 (이는 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> 

alt text

참고.

헤더에서 top.links 블록을 제거하지만 허드 블록

<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> 

alt text

만든 새 링크 템플릿 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입니다. 템플릿을 찾았지만 아무 것도 나타나지 않습니다.

alt text

나는 정말이와 단서입니다. 나는 여기서 완전히 잘못된 것을하고 있는가? 가치가있는 것을 위해, 여기 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; ?> 
+0

자신의 테마 인 경우'page.xml'을 편집 할 때 문제가 발생하지 않습니다. – clockworkgeek

+0

기본적으로 시작한 테마는 Magento의 기반 인 page.xml 파일을 사용합니다. 내 자신의 테마의 레이아웃 폴더 내에서 page.xml 파일을 사용하여이 작업을 재정의하려했지만 작동하지 않는 것 같습니다. 귀하의 회신에 감사드립니다. –

답변

2

"제거"규칙이 끝에 처리됩니다. 따라서 삽입하려는 블록의 이름을 변경해야합니다.

app/design/frontend/base/default/layout/customer.xml 
51:  <reference name="top.links"> 
52-   <action method="addLink" translate="label title" module="customer"><label>My Account</label><url helper="customer/getAccountUrl"/><title>My Account</title><prepare/><urlParams/><position>10</position></action> 
53-  </reference> 

링크

이 블록의 이름 top.links에 추가됩니다 지금 링크를 추가하는 방법을 찾습니다. 그래서 새 블록이 비어있는 것입니다. 해결책 : xml 파일에서 top.links가 있는지 검색하고 찾은 코드를 local.xml 파일에 추가하십시오.

+0

이 인스턴스를 사용할 때 이미 다른 XML 파일에서 똑같은 코드를 복사하여 붙여 넣었습니다. 위에서 제공 한 코드를 사용하여 의견을 보내 드리겠습니다. 귀하의 회신에 감사드립니다 greg0ire. –

+0

@Liam Spencer : 코드를 복사하여 붙여 넣은 후 참조 태그의 이름 속성을 새로 만든 블록의 이름과 일치 시키십시오. – greg0ire

+0

도움 주셔서 대단히 감사드립니다.이것은 나를 위해 일한 것 같아서 아마 Magento 시스템을 좀 더 이해할 수있었습니다. 나는 앞으로 더 많은 질문을 할 것입니다. 다시 한 번 감사드립니다! –

관련 문제