를 삽입하는 오픈 그래프 태그를 통해 사용자 지정 모듈 및 블록
-
12-12-2019 - |
문제
내가 사용하여 젠토 EE1.6
을 사용할 때 사용자 정의 블록 등을 표시하는 몇 가지 범주 안에 나 <head>
, 블록 표시되지 않습니다.하지만 만약 내가 사용하는 "page/html"
유형,모든 것이 잘...내 사용자 지정 등 일부 기능을 추가하기 위해 블록(인증을 받고,이미지의 url 등).
저를 도와주세요 이해하는 내가 무엇을 놓쳤다.여기에 나는 지금까지:
app/etc/modules/Wbx_Social.xml :
<?xml version="1.0"?>
<config>
<modules>
<Wbx_Social>
<active>true</active>
<codePool>local</codePool>
</Wbx_Social>
</modules>
</config>
app/code/local/Wbx/Social/etc/config.xml :
<?xml version="1.0"?>
<config>
<modules>
<Wbx_Social>
<version>0.1.0</version>
</Wbx_Social>
</modules>
<global>
[...]
<blocks>
<wbx_social>
<class>Wbx_Social_Block</class>
</wbx_social>
</blocks>
</global>
<frontend>
<layout>
<updates>
<wbx_social>
<file>wbx_social.xml</file>
</wbx_social>
</updates>
</layout>
</frontend>
</config>
app/code/local/Wbx/Social/Block/Opengraph.php :
class Wbx_Social_Block_Opengraph extends Mage_Core_Block_Template
{
/**
* @return int
*/
public function isActive()
{
return true; // Will be replaced with store config value
}
/* And other useful functions */
}
app/design/frontend/responsive/default/layout/wbx_social.xml :
<?xml version="1.0"?>
<layout>
<default>
<reference name="head">
<block type="wbx_social/opengraph" name="opengraph" as="opengraph" template="social/opengraph.phtml"/>
</reference>
</default>
</layout>
마지막으로 템플릿:응용 프로그램/디자인/프런트 엔드/대응/기본/템플릿/사회/opengraph.phtml:
<?php /* @var $this Wbx_Social_Block_Opengraph */ ?>
<?php if ($this->isActive()) : ?>
<meta property="fb:app_id" content="an id"/>
<meta property="og:type" content="website"/>
<meta property="og:site_name" content="a name"/>
<?php endif; ?>
이런 경우에,내가 잊지 않았 Wbx_Social_Helper_Data
빈 helper.
에 wbx_social.xml
, 빠르게 액세스할 수 있습니 변경 블록 등에 대한 type="core/template"
나 type="page/html"
(예를 들어),블록 올바르게 표시됩니다(없이 모든 액세스 사용자 정의 기능의 코스)
내가 정말 필요한 힌트를,그것은 몇 시간 동안 나는 찢는다.
해결책 2
인 발견의 기원이 문제입니다.이 문제는 실제로서 블록 Wbx_Social_Block_Opengraph
는 구현 getUrl()
방법입니다.큰 실수! Mage_Core_Block_Abstract
(조상의 나 block)은 이미 getUrl()
방법은 아니지만 다른 서명이 있습니다.나의 진짜 큰 문제는:이유는 도대체 나는 어떤 오류가 발생/경??그것이 그렇게 많은 시간이...
어쨌든,나는 나 자신의 방법 getOgUrl()
고 봐라!나의 태그를 표시되 내가 원하는 대로....
주셔서 감사합니다 많은 제안에,여러분!
다른 팁
Magento에는 여러 가지 블록 유형이 있습니다.App \ Code \ Core \ Mage \ Core \ Block \ \ 을 참조하십시오.
그 중 하나는 "목록"입니다.그것은 모든 아이들을 얻고 하나씩 하나씩 출력합니다.content
블록은 이렇게 작동합니다.
그러나 대부분의 블록에는 "템플릿"유형이 있습니다.연결되어 있고 렌더링하는 템플릿이 있습니다.예를 들어 블록은 이러한 유형이 있습니다.
헤드 (type="템플릿")에 일부 블록을 추가하려면 head.phtml 파일을 편집하고 $this->getChildHtml('opengraph')
를 사용하여 하위 블록을 호출해야합니다.