Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TASK] Add function to get all tags of all articles by one author #119

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions Classes/Domain/Model/Author.php
Original file line number Diff line number Diff line change
Expand Up @@ -409,4 +409,22 @@ public function setDetailsPage(int $page): self
$this->detailsPage = $page;
return $this;
}

/**
* Function to get all unique tags from all posts of the author.
*
* @return array $tags
*/
public function getAllTags(): array
{
$uniqueTags = [];
foreach ($this->getPosts() as $post) {
foreach ($post->getTags() as $tag) {
if (!array_key_exists($tag->getUid(), $uniqueTags)) {
$uniqueTags[$tag->getUid()] = $tag;
}
}
}
return $uniqueTags;
}
}
5 changes: 3 additions & 2 deletions Configuration/DataHandler/BlogSetupRelations.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@

$data = [];

// Tag and Category relation
// Relations
$data['pages']['NEW_firstBlogPostPage']['tags'] = 'NEW_blogTagTYPO3';
$data['pages']['NEW_firstBlogPostPage']['categories'] = 'NEW_blogCategoryTYPO3';
$data['pages']['NEW_firstBlogPostPage']['authors'] = 'NEW_blogAuthor';
$data['pages']['NEW_firstBlogPostPage']['comments'] = 'NEW_blogComment';
$data['pages']['NEW_firstBlogPostPage']['authors'] = 'NEW_blogAuthor';
$data['tx_blog_domain_model_author']['NEW_blogAuthor']['posts'] = 'NEW_firstBlogPostPage';

return $data;
13 changes: 13 additions & 0 deletions Resources/Private/Scss/frontend/components/_taglist.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* Taglist
*/
.blogtaglist {
padding: 0;
margin: -.25rem!important;
list-style: none;
}
.blogtaglist__item {
display: inline-block;
vertical-align: middle;
margin: .25rem;
}
1 change: 1 addition & 0 deletions Resources/Private/Scss/frontend/frontend.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
@import "components/comment";
@import "components/list";
@import "components/pagination";
@import "components/taglist";
@import "components/widget";
@import "components/widgetlist";

Expand Down
9 changes: 9 additions & 0 deletions Resources/Private/Templates/Post/ListPostsByAuthor.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ <h1 class="page__title">
<div class="taxonomy-description">
<p>{author.bio}</p>
</div>
<f:if condition="{author.allTags}">
<div class="taxonomy-tags">
<ul class="blogtaglist">
<f:for each="{author.allTags}" as="tag">
<li class="blogtaglist__item"><blogvh:link.tag class="blogbadge" tag="{tag}"/></li>
</f:for>
</ul>
</div>
</f:if>
<f:render partial="List" arguments="{_all}" />
</f:then>
<f:else>
Expand Down
2 changes: 1 addition & 1 deletion Resources/Public/Css/frontend.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.