Skip to content

Commit

Permalink
Added Tag list component
Browse files Browse the repository at this point in the history
  • Loading branch information
gergo85 committed Jul 12, 2022
1 parent 9aadb98 commit 8a7c6bc
Show file tree
Hide file tree
Showing 8 changed files with 119 additions and 9 deletions.
1 change: 1 addition & 0 deletions Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ public function registerComponents()
'Indikator\News\Components\Posts' => 'newsPosts',
'Indikator\News\Components\Post' => 'newsPost',
'Indikator\News\Components\Categories' => 'newsCategories',
'Indikator\News\Components\Tags' => 'newsTags',
'Indikator\News\Components\Subscribe' => 'newsSubscribe',
'Indikator\News\Components\Unsubscribe' => 'newsUnsubscribe'
];
Expand Down
10 changes: 5 additions & 5 deletions components/Categories.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ public function defineProperties()
'default' => '{{ :slug }}',
'type' => 'string',
],
'noPostsMessage' => [
'title' => 'indikator.news::lang.settings.no_posts_title',
'description' => 'indikator.news::lang.settings.no_posts_description',
'noCategoryMessage' => [
'title' => 'indikator.news::lang.settings.no_category_title',
'description' => 'indikator.news::lang.settings.no_category_description',
'type' => 'string',
'default' => Lang::get('indikator.news::lang.settings.no_posts_found'),
'default' => Lang::get('indikator.news::lang.settings.no_category_found'),
'showExternalParam' => false
],
'categoryFilter' => [
Expand Down Expand Up @@ -78,7 +78,7 @@ public function onRun()

$this->currentCategorySlug = $this->page['currentCategorySlug'] = $this->property('slug');
$this->categoryPage = $this->page['categoryPage'] = $this->property('categoryPage');
$this->page['noPostsMessage'] = $this->property('noPostsMessage');
$this->page['noCategoryMessage'] = $this->property('noCategoryMessage');
$this->categories = $this->page['categories'] = $this->listCategories();
}

Expand Down
69 changes: 69 additions & 0 deletions components/Tags.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?php namespace Indikator\News\Components;

use Cms\Classes\ComponentBase;
use Cms\Classes\Page;
use Indikator\News\Models\Posts;
use Lang;

class Tags extends ComponentBase
{
public function componentDetails()
{
return [
'name' => 'indikator.news::lang.component.tags',
'description' => ''
];
}

public function defineProperties()
{
return [
'slug' => [
'title' => 'indikator.news::lang.settings.tags_slug_title',
'description' => 'indikator.news::lang.settings.tags_slug_description',
'default' => '{{ :slug }}',
'type' => 'string',
],
'noTagsMessage' => [
'title' => 'indikator.news::lang.settings.no_tags_title',
'description' => 'indikator.news::lang.settings.no_tags_description',
'type' => 'string',
'default' => Lang::get('indikator.news::lang.settings.no_tags_found'),
'showExternalParam' => false
],
'tagPage' => [
'title' => 'indikator.news::lang.settings.tag_page_title',
'description' => 'indikator.news::lang.settings.tag_page_description',
'type' => 'dropdown',
'default' => ''
]
];
}

public function getTagPageOptions()
{
return Page::sortBy('baseFileName')->lists('baseFileName', 'baseFileName');
}

public function onRun()
{
$tags = [];
$news = Posts::where('status', 1)->where('published_at', '<=', date('Y-m-d H:i:00'))->get()->all();

foreach ($news as $post) {
foreach ($post['tags'] as $tag) {
if (! in_array($tag, $tags)) {
$tags[] = $tag;
}
}
}

usort($tags, function($item1, $item2) {
return $item1 <=> $item2;
});

$this->page['tags'] = $tags;
$this->page['noTagsMessage'] = $this->property('noTagsMessage');
$this->page['tagPage'] = $this->property('tagPage');
}
}
2 changes: 1 addition & 1 deletion components/categories/default.htm
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@
</ul>
{% endif %}
{% else %}
<span class="post-nodata">{{ noPostsMessage }}</span>
<span class="post-nodata">{{ noCategoryMessage }}</span>
{% endfor %}
13 changes: 13 additions & 0 deletions components/tags/default.htm
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{% set tags = __SELF__.tags %}

{% for tag in tags %}
{% if loop.first %}
<ul>
{% endif %}
<li><a href="/{{ tagPage }}/{{ tag }}">{{ tag }}</a></li>
{% if loop.last %}
</ul>
{% endif %}
{% else %}
<span class="post-nodata">{{ noTagsMessage }}</span>
{% endfor %}
11 changes: 11 additions & 0 deletions lang/en/lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@
'posts' => 'Display posts',
'post' => 'Post content',
'categories' => 'Categories',
'tags' => 'Tags',
'subscribe' => 'Subscriber form',
'unsubscribe' => 'Unsubscribe form'
],
Expand All @@ -221,6 +222,12 @@
'no_posts_title' => 'No posts message',
'no_posts_description' => 'Message to display in the post list in case if there are no posts. This property is used by the default component partial.',
'no_posts_found' => 'No posts found',
'no_category_title' => 'No categories message',
'no_category_description' => 'Message to display in the category list in case if there are no categories.',
'no_category_found' => 'No categories found',
'no_tags_title' => 'No tags message',
'no_tags_description' => 'Message to display in the tag list in case if there are no tag.',
'no_tags_found' => 'No tags found',
'posts_order_title' => 'Post order',
'posts_order_description' => 'Attribute on which the posts should be ordered',
'post_title' => 'Post page',
Expand All @@ -240,6 +247,10 @@
'category_filter_description' => 'Enter a category slug or URL parameter to filter the posts by. Leave empty to show all posts.',
'nested_category_posts_title' => 'Nested Posts',
'nested_category_posts_description' => 'Display posts which are in a nested category.',
'tag_slug_title' => 'Tag slug',
'tag_slug_description' => 'Look up the tag using the supplied slug value. This property is used by the default component partial for marking the currently active tag.',
'tag_page_title' => 'Tag page',
'tag_page_description' => 'Name of the tag page file for the tag links. This property is used by the default component partial.',
'links' => 'Links'
],
'sorting' => [
Expand Down
15 changes: 15 additions & 0 deletions lang/hu/lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@
'posts' => 'Hírek listázása',
'post' => 'Bejegyzés mutatása',
'categories' => 'Hír kategóriák',
'tags' => 'Címkék',
'subscribe' => 'Űrlap feliratkozáshoz',
'unsubscribe' => 'Űrlap leiratkozáshoz'
],
Expand All @@ -219,6 +220,12 @@
'no_posts_title' => 'Nincs találat',
'no_posts_description' => 'A bejegyzés listában megjelenő üzenet abban az esetben, ha nincsenek bejegyzések.',
'no_posts_found' => 'Nincsenek bejegyzések',
'no_category_title' => 'Nincs találat',
'no_category_description' => 'A kategória listában megjelenő üzenet abban az esetben, ha nincsenek kategóriák.',
'no_category_found' => 'Nincsenek kategóriák',
'no_tags_title' => 'Nincs találat',
'no_tags_description' => 'A címke listában megjelenő üzenet abban az esetben, ha nincsenek címkék.',
'no_tags_found' => 'Nincsenek címkék',
'posts_order_title' => 'Bejegyzések sorrendje',
'posts_order_description' => 'Ez alapján rendeződnek a bejegyzések.',
'post_title' => 'Bejegyzés lapja',
Expand All @@ -230,10 +237,18 @@
'list_notfeatured' => 'Csak a nem kiemeltek',
'translated_title' => 'Lefordított bejegyzések',
'translated_description' => 'Bejegyzés elrejtése, ha annak a nyelve nem egyezik meg a honlapéval.',
'category_slug_title' => 'Kategória webcím',
'category_slug_description' => '',
'category_page_title' => 'Kategória aloldal',
'category_page_description' => 'Adja meg a kategória fájl nevét. Ennek alapján lesznek generálva a kategória linkek webcíme.',
'category_filter_title' => 'Kategória szűrés',
'category_filter_description' => 'Adja meg a kategória webcímét, ami alapján szűrve lesznek a bejegyzések. Üresen hagyva minden bejegyzés meg fog jelenni.',
'nested_category_posts_title' => 'Alkategória',
'nested_category_posts_description' => 'Alkategóriához tartozó bejegyzések megjelenítése.',
'tag_slug_title' => 'Címke webcím',
'tag_slug_description' => '',
'tag_page_title' => 'Címke aloldal',
'tag_page_description' => 'Adja meg a címke fájl nevét. Ennek alapján lesznek generálva a címke linkek webcíme.',
'links' => 'Linkek'
],
'sorting' => [
Expand Down
7 changes: 4 additions & 3 deletions updates/version.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
1.8.4: Added the preview feature for posts.
1.8.5: Added more options for Settings page.
1.8.6:
- !!! Reworked again the sending newsletter feature.
- Reworked again the sending newsletter feature.
- update_send_feature_2.php
1.9.0:
- Added categories feature.
Expand Down Expand Up @@ -134,9 +134,10 @@
1.11.8: Fixed bug showing the previous and next post.
1.11.9: Fixed the email sending bug.
1.12.0:
- !!! New configuration was added. If you had no categories enabled or non set, you need to disable newsletter_subscriber_categories
- New configuration was added. If you had no categories enabled or non set, you need to disable newsletter_subscriber_categories
- Adding nested categories support and multiple category news.
- If no category is set, and newsletter_subscriber_categories is enabled, none of your subscriber will receive any newsletter anymore.
- Added prev/next post in category
- Added prev / next post in category.
- add_nested_categories_support.php
- create_posts_categories_table.php
1.12.1: Added Tag list component.

0 comments on commit 8a7c6bc

Please sign in to comment.