2011-06-11 3 views
0

액체 (https://github.com/tobi/liquid/)를 사용하여 템플릿의 콘텐츠를 렌더링하고 있습니다. 홈페이지에서 "최근 활동"섹션을보고 싶습니다.이 섹션에서는 날짜별로 정렬 된 세 가지 유형의 컨텐츠 유형에 대한 최신 업데이트를 4 개까지 찾습니다.액체 템플릿 언어로 콘텐츠 유형 결합

액체와 함께 이런 것이 가능합니까?

그래서 일반 언어로 쿼리는 .. 같은 것

감사합니다, 마크 "CONTENT_TYPE_1, 2 또는 3에서 날짜별로 정렬 된 네 개의 최신 항목을 선택합니다."

답변

1

content_type에 의해 게시 카테고리를 의미한다고 가정합니다. 당신은 당신의 게시물의 YAML Front Matter

category: type_1 

을 추가하거나 type_1/_posts 폴더에서 해당 게시물을 넣어 귀하의 게시물을 분류 할 수 있습니다. 우리가 이것을 가지고 있다면, 당신이 원하는 것을하는 약간 끈적한 방법이 있습니다 :

<div> 
    {% assign count1 = true %} 
    {% assign count2 = true %} 
    {% assign count3 = true %} 
    {% assign count4 = true %} 
    {% for post in site.posts %} 
    {% if post.categories contains 'type_1' or post.categories contains 'type_2' or ... %} 
     {% if count1 == true or count2 == true or count3 == true or count4 == true %} 
      <li><span>{{ post.date | date_to_string }}</span> &raquo; <a href="{{ post.url }}">{{ post.title }}</a></li> 
      {% if count1 == true %} 
       {% assign count1 = false %} 
      {% elsif count2 == true %} 
       {% assign count2 = false %} 
      {% elsif count3 == true %} 
       {% assign count3 = false %} 
      {% elsif count4 == true %} 
       {% assign count4 = false %} 
      {% endif %} 
     {% endif %} 
    {% endif %} 
    {% endfor %} 
</div>