-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
40 additions
and
300 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,326 +1,63 @@ | ||
## Components | ||
# Good News | ||
|
||
### ArticlePage component | ||
[![Build Status](https://travis-ci.org/lovata/oc-good-news-plugin.svg?branch=master)](https://travis-ci.org/lovata/oc-good-news-plugin) | ||
[![Coverage Status](https://coveralls.io/repos/github/lovata/oc-good-news-plugin/badge.svg?branch=master)](https://coveralls.io/github/lovata/oc-good-news-plugin?branch=master) | ||
[![Maintainability](https://api.codeclimate.com/v1/badges/e0d44449f4ea93a1da01/maintainability)](https://codeclimate.com/github/lovata/oc-good-news-plugin/maintainability)[![Crowdin](https://d322cqt584bo4o.cloudfront.net/good-news-for-october-cms/localized.svg)](https://crowdin.com/project/good-news-for-october-cms) | ||
[![SemVer](http://img.shields.io/SemVer/2.0.0.png)](http://semver.org/spec/v2.0.0.html) | ||
[![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0) | ||
|
||
The component allows to work with ArticleItem class objects. | ||
Simple blogging plugin for October CMS developed by [LOVATA](https://lovata.com). | ||
|
||
The ArticlePage class is extended from [ElementPage](https://github.com/lovata/oc-toolbox-plugin/wiki/ElementPage) class. | ||
![Good News Banner](assets/images/good-news-banner.png) | ||
|
||
Usage example: | ||
```twig | ||
[ArticlePage] | ||
slug = "{{ :slug }}" | ||
slug_required = 1 | ||
== | ||
## Overview | ||
|
||
{# Get 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.description|raw }}</div> | ||
</div> | ||
``` | ||
|
||
### ArticleData component | ||
|
||
The component allows to work with ArticleItem class objects. | ||
|
||
The ArticleData class is extended from [ElementData](https://github.com/lovata/oc-toolbox-plugin/wiki/ElementData) class. | ||
|
||
Usage example: | ||
```twig | ||
{# Get 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.description|raw }}</div> | ||
</div> | ||
{% endif %} | ||
``` | ||
|
||
### ArticleList component | ||
|
||
The component allows to work with ArticleCollection class objects. | ||
|
||
#### Method list | ||
|
||
##### make($arElementIDList = null) | ||
**Example: render article list** | ||
|
||
Get collection of articles, apply sorting + filter by published status | ||
```twig | ||
{% 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 article collection, apply sorting + filter by published status + [Pagination](https://github.com/lovata/oc-toolbox-plugin/wiki/Components#pagination) component | ||
```twig | ||
{# Get article collection #} | ||
{% set obArticleList = ArticleList.make().sort('publish|desc').published() %} | ||
{# Get array with pagination buttons #} | ||
{% set iPage = Pagination.getPageFromRequest() %} | ||
{% set arPaginationList = Pagination.get(iPage, obArticleList.count()) %} | ||
{# Apply pagination to article collection and get array with article items #} | ||
{% set arArticleList = obArticleList.page(iPage, Pagination.getCountPerPage()) %} | ||
{% if arArticleList is not empty %} | ||
{# Render article list #} | ||
<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> | ||
{# Render pagination buttons #} | ||
{% if arPaginationList is not empty %} | ||
{% for arPagination in arPaginationList %} | ||
<a href="/{{ arPagination.value }}" class="{{ arPagination.class }}">{{ arPagination.name }}</a> | ||
{% endfor %} | ||
{% endif %} | ||
{% endif %} | ||
``` | ||
|
||
### ArticleCategoryPage component | ||
|
||
The component allows to work with CategoryItem class objects. | ||
|
||
The ArticleCategoryPage class is extended from [ElementPage](https://github.com/lovata/oc-toolbox-plugin/wiki/ElementPage) class. | ||
|
||
Usage example: | ||
```twig | ||
[ArticleCategoryPage] | ||
slug = "{{ :slug }}" | ||
slug_required = 1 | ||
== | ||
{# Get 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> | ||
``` | ||
|
||
### ArticleCategoryData component | ||
|
||
The component allows to work with CategoryItem class objects. | ||
|
||
The ArticleCategoryData class is extended from [ElementData](https://github.com/lovata/oc-toolbox-plugin/wiki/ElementData) class. | ||
Good News is a simple and easy-to-use blogging plugin. It's provided free of charge and includes the following set of features: | ||
|
||
Usage example: | ||
```twig | ||
* Managing posts | ||
* Managing categories | ||
* Adding categories list to the site navigation | ||
* Adding latest posts block to the page | ||
* Adding filtered category block to the page | ||
|
||
{# Get 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 %} | ||
``` | ||
|
||
### ArticleCategoryList component | ||
|
||
The component allows to work with CategoryCollection class objects. | ||
|
||
#### Method list | ||
|
||
##### make($arElementIDList = null) | ||
**Example: render of category list** | ||
|
||
Get tree of categories. Example is used in render of category menu. | ||
```twig | ||
{% 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 %} | ||
``` | ||
|
||
### ArticleCollection class | ||
> Please note, the architecture of the plugin allows [extending](https://octobercms.com/docs/plugin/extending) the existing methods, fields and other data without interfering with original source code! | ||
The class allows to work with a cached list of articles. | ||
The development of Good News plugin is guided by the similar philosophies of October CMS and Unix like operating systems, where the main focus is to create simple microarchitecture solutions that communicate with each other through smart APIs. | ||
|
||
The ArticleCollection class is extended from [ElementCollection](https://github.com/lovata/oc-toolbox-plugin/wiki/ElementCollection) class. | ||
One one hand, this approach allows keeping performance, security, and functionality of the code to a high standard. On the other hand, it provides a clean and smooth back-end UI/UX that isn't over-bloated with the features. | ||
|
||
The ArticleCollection class returns arrays of [ArticleItem](https://github.com/lovata/oc-shopaholic-plugin/wiki/ArticleItem) class objects. | ||
## Installation | ||
|
||
#### Method List: | ||
##### sort($sSorting) | ||
Regardless of the installation type you choose, you must install [Toolbox plugin](https://octobercms.com/plugin/lovata-toolbox), which is a required dependency for Shopaholic. | ||
|
||
Method sorts the elements of a collection by $sSorting value. | ||
Available sorting value: | ||
* 'no' - default value | ||
* 'publish|asc' | ||
* 'publish|desc' | ||
* 'view|asc' | ||
* 'view|desc' | ||
```php | ||
$obList = ArticleCollection::make([1,2,10,15])->sort('publish|desc'); | ||
``` | ||
### Artisan | ||
|
||
##### published() | ||
Using the Laravel’s CLI is the fastest way to get started. Just run the following commands in a project’s root directory: | ||
|
||
Method applies a filter by publish status and publish date for the elements of a collection | ||
```php | ||
$obList = ArticleCollection::make([1,2,10,15])->published(); | ||
``` | ||
|
||
##### category($iCategoryID, $bWithChildren = false) | ||
* $iCategoryID - article category ID or array with ID of categories | ||
* $bWithChildren - flag, if == true, then method returns list of articles for category with ID == $iCategoryID + articles of children categories | ||
|
||
Method applies a filter by the category ID. | ||
```php | ||
$obList = ArticleCollection::make()->category(2); | ||
``` | ||
```php | ||
$obList = ArticleCollection::make()->category(2, true); | ||
```bash | ||
php artisan plugin:install lovata.toolbox | ||
php artisan plugin:install lovata.goodnews | ||
``` | ||
```php | ||
$obList = ArticleCollection::make()->category([2, 5, 6]); | ||
``` | ||
```php | ||
$obList = ArticleCollection::make()->category([2, 5, 6], true); | ||
``` | ||
|
||
### CategoryCollection class | ||
|
||
The class allows to work with a cached list of categories. | ||
|
||
The CategoryCollection class is extended from [ElementCollection](https://github.com/lovata/oc-toolbox-plugin/wiki/ElementCollection) class. | ||
|
||
The CategoryCollection class returns arrays of CategoryItem class objects. | ||
|
||
#### Method List: | ||
##### tree() | ||
|
||
Method returns category list of top level. Method returns only active categories. | ||
```php | ||
$obList = CategoryCollection::make()->tree(); | ||
``` | ||
|
||
##### active() | ||
|
||
Method applies a filter to the field "active" = true for the elements of a collection. | ||
```php | ||
$obList = CategoryCollection::make([1,2,10,15])->active(); | ||
``` | ||
|
||
### ArticleItem class | ||
|
||
The class allows to work with a cached data array of Article model. | ||
## Documentation | ||
|
||
The ArticleItem class is extended from [ElementItem](https://github.com/lovata/oc-toolbox-plugin/wiki/ElementItem) class. | ||
The complete official documentation of the ecosystem can be found [here](https://github.com/lovata/oc-good-news-plugin/wiki). | ||
|
||
## Field list | ||
* (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 | ||
## Quality standards | ||
|
||
### CategoryItem class | ||
We ensure the high quality of our plugins and provide you with full support. All of our plugins have extensive documentation. The quality of our plugins goes through rigorous testing, we have launched automated testing for all of our plugins. Our code conforms with the best writing and structuring practices. All this guarantees the stable work of our plugins after they are updated with new functionality and ensures their smooth integration. | ||
|
||
The class allows to work with a cached data array of Category model. | ||
## Get involved | ||
|
||
The CategoryItem class is extended from [ElementItem](https://github.com/lovata/oc-toolbox-plugin/wiki/ElementItem) class. | ||
If you're interested in the improvement of this project you can help in the following ways: | ||
* bug reporting and new feature requesting by creating issues on plugin [GitHub page](https://github.com/lovata/oc-good-news-plugin/issues); | ||
* contribution to a project following these [instructions](https://github.com/lovata/oc-good-news-plugin/blob/master/CONTRIBUTING.md); | ||
* localization to your language using [Crowdin](https://crowdin.com/project/good-news-for-october-cms) service. | ||
|
||
## Field list | ||
* (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 parent category | ||
* (array) **children_id_list** - array with **active** children category ID list | ||
* CategoryCollection **children** - collection with **active** children category | ||
Let us know if you have any other questions, ideas or suggestions! Just drop a line at [email protected]. | ||
|
||
## License | ||
|
||
© 2019, [LOVATA Group, LLC](https://github.com/lovata) under [GNU GPL v3](https://opensource.org/licenses/GPL-3.0). | ||
|
||
Developed by [Andrey Kharanenka](https://github.com/kharanenka). | ||
Developed by [Andrey Kharanenka](https://github.com/kharanenka). |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
files: | ||
- source: /lang/en/*php | ||
translation: /lang/%two_letters_code%/%original_file_name% |