-
Notifications
You must be signed in to change notification settings - Fork 10
Home
It allows working with the ArticleItem
class objects.
The ArticlePage
class is extended from the ElementPage
class.
Usage example:
[ArticlePage]
slug = "{{ :slug }}"
slug_required = 1
==
{# Get an article item #}
{% set obArticle = ArticlePage.get() %}
<div data-id="{{ obArticle.id }}">
<h1>{{ obArticle.title }}</h1>
<span>{{ obArticle.published_start.format('F d, Y') }}</span>
{% if obArticle.preview_image is not empty %}
<img src="{{ obArticle.preview_image.path }}" title="{{ obArticle.preview_image.title }}" alt="{{ obArticle.preview_image.description }}">
{% endif %}
<div>{{ obArticle.content|raw }}</div>
</div>
It allows working with the ArticleItem
class objects.
The ArticleData
class is extended from ElementData
class.
Usage example:
{# Get an article item with ID = 10 #}
{% set obArticle = ArticleData.get(10) %}
{% if obArticle.isNotEmpty() %}
<div data-id="{{ obArticle.id }}">
<h2>{{ obArticle.title }}</h2>
<span>{{ obArticle.published_start.format('F d, Y') }}</span>
{% if obArticle.preview_image is not empty %}
<img src="{{ obArticle.preview_image.path }}" title="{{ obArticle.preview_image.title }}" alt="{{ obArticle.preview_image.description }}">
{% endif %}
<div>{{ obArticle.content|raw }}</div>
</div>
{% endif %}
It allows working with the ArticleCollection
class objects.
Usage example (render article list):
Get a collection of articles, apply sorting + filter by published status.
{% set obArticleList = ArticleList.make().sort('publish|desc').published() %}
{% if obArticleList.isNotEmpty() %}
<div class="article-list-wrapper">
{% for obArticle in obArticleList %}
<div data-id="{{ obArticle.id }}">
<h2>{{ obArticle.title }}</h2>
<span>{{ obArticle.published_start.format('F d, Y') }}</span>
{% if obArticle.preview_image is not empty %}
<img src="{{ obArticle.preview_image.path }}" title="{{ obArticle.preview_image.title }}" alt="{{ obArticle.preview_image.description }}">
{% endif %}
<div>{{ obArticle.preview_text }}</div>
</div>
{% endfor %}
</div>
{% endif %}
Get an article collection, apply sorting + filter by published status + Pagination
component.
{# Get an article collection #}
{% set obArticleList = ArticleList.make().sort('publish|desc').published() %}
{# Get an array with pagination buttons #}
{% set iPage = Pagination.getPageFromRequest() %}
{% set arPaginationList = Pagination.get(iPage, obArticleList.count()) %}
{# Apply a pagination to the article collection and get an array with article items #}
{% set arArticleList = obArticleList.page(iPage, Pagination.getCountPerPage()) %}
{% if arArticleList is not empty %}
{# Render the article list #}
<div class="article-list-wrapper">
{% for obArticle in arArticleList %}
<div data-id="{{ obArticle.id }}">
<h2>{{ obArticle.title }}</h2>
<span>{{ obArticle.published_start.format('F d, Y') }}</span>
{% if obArticle.preview_image is not empty %}
<img src="{{ obArticle.preview_image.path }}" title="{{ obArticle.preview_image.title }}" alt="{{ obArticle.preview_image.description }}">
{% endif %}
<div>{{ obArticle.preview_text }}</div>
</div>
{% endfor %}
</div>
{# Render the pagination buttons #}
{% if arPaginationList is not empty %}
{% for arPagination in arPaginationList %}
<a href="/{{ arPagination.value }}" class="{{ arPagination.class }}">{{ arPagination.name }}</a>
{% endfor %}
{% endif %}
{% endif %}
It allows working with the CategoryItem
class objects.
The ArticleCategoryPage
class is extended from the ElementPage
class.
Usage example:
[ArticleCategoryPage]
slug = "{{ :slug }}"
slug_required = 1
==
{# Get a category item #}
{% set obCategory = ArticleCategoryPage.get() %}
<div data-id="{{ obCategory.id }}">
<h1>{{ obCategory.name }}</h1>
{% if obCategory.preview_image is not empty %}
<img src="{{ obCategory.preview_image.path }}" title="{{ obCategory.preview_image.title }}" alt="{{ obCategory.preview_image.description }}">
{% endif %}
<div>{{ obCategory.description|raw }}</div>
{% if obCategory.children.isNotEmpty() %}
<ul>
{% for obChildCategory in obCategory.children %}
<li>{{ obChildCategory.name }}</li>
{% endfor %}
</ul>
{% endif %}
</div>
It allows working with the CategoryItem
class objects.
The ArticleCategoryData
class is extended from the ElementData
class.
Usage example:
{# Get a category item with ID = 10 #}
{% set obCategory = ArticleCategoryData.get(10) %}
{% if obCategory.isNotEmpty() %}
<div data-id="{{ obCategory.id }}">
<h2>{{ obCategory.name }}</h2>
{% if obCategory.preview_image is not empty %}
<img src="{{ obCategory.preview_image.path }}" title="{{ obCategory.preview_image.title }}" alt="{{ obCategory.preview_image.description }}">
{% endif %}
<div>{{ obCategory.description|raw }}</div>
{% if obCategory.children.isNotEmpty() %}
<ul>
{% for obChildCategory in obCategory.children %}
<li>{{ obChildCategory.name }}</li>
{% endfor %}
</ul>
{% endif %}
</div>
{% endif %}
It allows working with the CategoryCollection
class objects.
Usage example (render of the category list):
Get a tree of categories. An example is used in the render of the category menu.
{% set obCategoryList = ArticleCategoryList.make().tree() %}
{% if obCategoryList.isNotEmpty() %}
<ul class="category-menu-wrapper">
{% for obCategory in obCategoryList %}
<li data-id="{{ obCategory.id }}">{{ obCategory.name }}
{% if obCategory.children.isNotEmpty() %}
<ul class="category-child-menu-wrapper">
{% for obChildCategory in obCategory.children %}
<li>{{ obChildCategory.name }}</li>
{% endfor %}
</ul>
{% endif %}
</li>
{% endfor %}
</ul>
{% endif %}
It allows working with a cached list of articles.
The ArticleCollection
class is extended from the ElementCollection
class and returns arrays of the ArticleItem
class objects.
It sorts the elements of a collection by the $sSorting
values:
-
no
β by ID (default); -
publish|asc
β by publishing date (ascending); -
publish|desc
β by publishing date (descending); -
view|asc
β by number of views (ascending); -
view|desc
β by number of views (descending).
Usage example:
$obList = ArticleCollection::make([1,2,10,15])->sort('publish|desc');
It applies a filter by publishing status and publish the date for the elements of a collection.
Usage example:
$obList = ArticleCollection::make([1,2,10,15])->published();
It applies a filter by the $iCategoryID
values:
-
$iCategoryID
β article category ID or array with IDs of the categories; -
$bWithChildren
β flag, if equalstrue
, then method returns the list of the articles for category with$iCategoryID
+ articles of children categories.
Usage examples:
$obList = ArticleCollection::make()->category(2);
$obList = ArticleCollection::make()->category(2, true);
$obList = ArticleCollection::make()->category([2, 5, 6]);
$obList = ArticleCollection::make()->category([2, 5, 6], true);
It allows working with a cached list of the categories.
The CategoryCollection
class is extended from ElementCollection
class and returns arrays of the CategoryItem
class objects.
It returns the category list of the top level (only active categories).
Usage example:
$obList = CategoryCollection::make()->tree();
It applies a filter to the field active
in the state true
for the elements of a collection.
Usage example:
$obList = CategoryCollection::make([1,2,10,15])->active();
It allows working with a cached data array of the Article
model.
The ArticleItem
class is extended from the ElementItem
class.
- (int)
id
- (string)
status_id
- (string)
title
- (string)
slug
- (\October\Rain\Argon\Argon)
published_start
- (\October\Rain\Argon\Argon)
published_stop
- (\October\Rain\Argon\Argon)
created_at
- (\October\Rain\Argon\Argon)
updated_at
- (string)
preview_text
- \System\Models\File
preview_image
- (string)
content
- \System\Models\File[]
images
- (int)
view_count
- (int)
category_id
- CategoryItem
category
β object of parent category
It allows working with a cached data array of the Category
model.
The CategoryItem
class is extended from the ElementItem
class.
- (int)
id
- (string)
name
- (string)
slug
- (string)
code
- (string)
preview_text
- \System\Models\File
preview_image
- (string)
description
- \System\Models\File[]
images
- (int)
nest_depth
- (int)
parent_id
- CategoryItem
parent
β object of the parent category - (array)
children_id_list
β array with theactive
children category ID list - CategoryCollection
children
β collection with theactive
children category