十月cms博客插件:如何在单击按钮时更新组件

时间:2018-03-08 09:06:08

标签: php laravel octobercms octobercms-plugins octobercms-backend

description = "Display Blog list"

[viewBag]
snippetCode = "post-list.htm"
snippetName = "Display Blog list"
snippetProperties[heading][title] = "Heading"
snippetProperties[heading][type] = "string"
snippetProperties[heading][default] = "News & Events"
snippetProperties[heading][options][] = ""

[blogPosts]
pageNumber = "{{ :page }}"
postsPerPage = 6
noPostsMessage = "No posts found"
sortOrder = "published_at desc"
categoryPage = "article-post"
postPage = "article-post"
==
<?php
function onLoadMore()
{
    $this['pageNumber'] = 10;
}
?>
==
<section class="section section-fat news">
    <div class="section-header">
        <div class="container text-center">
            <h2 class="heading-large">{{ heading|raw }}</h2>
        </div>
    </div>  
    
    <div class="container-fluid">
        <div id="loadmore" class="row">
{% set posts = blogPosts.posts %}

{# fetch all posts in Blog #}
{% for post in posts %}

  <div class="item col-sm-6 col-md-4 col-lg-6">
      <a href="{{ post.url }}" class="news-box">
          <div class="news-box-container">
              <div class="news-box-content">
                  <h4>{{ post.title }}</h4>
                  <p>{% if post.categories.count %} in {% endif %} {% for category in post.categories %}{{ category.name }}{% if not loop.last %}, {% endif %} {% endfor %} {{ post.published_at|date('M d, Y') }}</p>
              </div>
          </div>
          <div class="news-box-arrow"><i class="icon-angle-circle-right"></i></div>
          <div class="news-box-image" style="background-image: url('{{ post.featured_images[0].thumb(2500,1000) }}');"></div>
      </a>
  </div>

{% else %}
    <div class="text-center">{{ noPostsMessage }}</div>
{% endfor %}

 <div class="text-center news-load">
    <a data-request="onLoadMore" data-request-update="'load-more': '#loadmore'" data-attach-loading class="btn btn-lg btn-invert">Load More</a>
</div>

</div>
</section>

这是我为展示博客而创建的代码段的代码。

我正在使用Rainlab的博客插件,有没有一种方法可以自定义或修改可以帮助我更新组件的代码?我想在每次单击按钮时向“postsPerPage = 6”添加3个帖子。我一直在努力为这个问题找到一个解决方案或插件,但遗憾的是我找不到一个。

0 个答案:

没有答案