2016-12-20 7 views
0

Apsotrophe CMS에서 일부 내용을 보여주는 데 어려움을 겪고 있습니다. 나는 설명 필드를 만들 apostrophe-pieces을 사용하고페이지 인덱스에 조각의 위젯 내용을 어떻게 표시합니까?

는 :

{ 
    name: 'description', 
    label: 'Description', 
    type: 'singleton', 
    widgetType: 'apostrophe-rich-text', 
    options: { 
    toolbar: [ 'Bold', 'Italic', 'Link', 'Unlink' ] 
    } 
} 

나는 그것이 사용자 정의 페이지의 index.html을보기에 표시하고 싶습니다.

그러나 {{ apos.singleton(data.piece, 'description', 'apostrophe-rich-text') }}을 사용하면 오류가 발생하고 페이지를 렌더링 할 수 없습니다. 그것은 단지 /lib/modules/basics-pages/views/index.html에서

show.html 작동, 내 코드는 다음과 같습니다

{% extends "apostrophe-pages:outerLayoutBase.html" %} 

{% block content %} 
    <div class="basics-grid"> 
    {% for piece in data.pieces %} 
     <article> 
     <h4>{{ piece.title }}</h4> 
     {% set image = apos.images.first(piece.icon) %} 
     {% if image %} 
      <img src="{{ apos.attachments.url(image, { size: 'one-sixth' }) }}" /> 
     {% endif %} 
     <div class="desc"> 
     {{ apos.singleton(data.piece, 'description', 'apostrophe-rich-text') }} 
     </div> 
     </article> 
    {% endfor %} 
    </div> 
{% endblock %} 

누군가가 싱글 위젯의 내용을 표시하는 데 사용할 올바른 코드 좀 도와 주 시겠어요?

답변

0

내가 아는 곳은 P'unk Avenue의 Apostrophe의 수석 개발자입니다.

이 코드 :

{% for piece in data.pieces %}

당신이 piece라는 루프 변수를 나타냅니다. 그것이 당신이 원하는 것입니다.

이 코드는 :

{{ apos.singleton(data.piece, 'description', 'apostrophe-rich-text') }}

data의 속성으로 piece을 찾습니다 및 루프 변수를 무시합니다.

data.을 제거하면 도움이됩니다.

당신은 추가 할 수 있습니다 :

{{ apos.singleton(piece, 'description', 'apostrophe-rich-text', { edit: false }) }}

유용보다 더 혼란 스러울 것 인덱스 페이지에서 인라인 편집을 방지하기 위해.