OctoberCMS-同一页面中的多个Blog组件(Rainlab Blog)重写

时间:2019-01-31 08:21:37

标签: php laravel octobercms octobercms-plugins twig-extension

我是OctoberCMS的新手,现在很困,我面临在同一页面中多次使用自定义博客文章组件(覆盖Rainlab博客文章)的问题。

说我已经为 postLists 创建了默认 blogPosts 的别名,并且定义了自定义HTML结构,并且运行良好,没有问题。

现在,我要在页面中将 postLists 帖子结构用于三个不同的类别,在这里我被困住了,因为当我像这样将变量传递给组件时,{ % component 'postLists' categoryFilter='news' %}确实可以对于类别过滤器不起作用,如果我从拖放组件UI中选择一个类别,它将成为页面的全局categoryFilter设置。

screenshot

这是我的要求。

requirements

我的postList组件代码:-

{% set posts = __SELF__.posts %}
{% for post in posts %}

<div class="col-sm-6">
      <div class="row">
        <div class="col-sm-4 col-4 content_body_img">
            <a href="{{ post.url }}">
        {% if post.featured_images.count > 0 %}
            <img class="media-object" src="{{ post.featured_images.first.getThumb(108, 108) }}" />
        {% else %}
            <img class="media-object" src="http://placehold.it/108x108" />
        {% endif %}
    </a>
        </div>
        <div class="col-sm-8 col-8">
          <p><a href="{{ post.url }}">{{ post.title }}</a></p>
          <!--location_date-->
          <div class="location_date">
            <ul>
              <li><i class="fa fa-calendar"></i><span> {{ post.published_at|date('j F, Y') }}<span></li>
              <li><i class="fa fa-map-marker"></i>Dubai</li>
            </ul>
          </div>
          <!--location_date end -->
        </div>
      </div>
    </div>
    <!--content_body_img end -->
{% else %}
<div class="col-sm-6 col-6 col-lg-3">{{ noPostsMessage }}</div>
{% endfor %}

请帮助我,我们将不胜感激。

感谢桑尼

1 个答案:

答案 0 :(得分:0)

这是静态方法-我将同时发布动态方法

最好(可能是最简单的解决方案)是(如果您只想显示帖子)为每个选项卡添加3 Post List componentDifferent Category filter选项。

enter image description here

它应该完成您的工作

  

如果只需要显示其他列表,请确保这是最佳解决方案。

相关问题