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 a category filter #2

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

obi12341
Copy link

@obi12341 obi12341 commented Sep 22, 2016

Added ability to filter by category.

Copy link
Owner

@johannessteu johannessteu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @obi12341,
Thanks for the change! I left some comments :)

@@ -38,4 +38,13 @@ prototype(JohannesSteu.Neos.News:NewsFilter) < prototype(TYPO3.Neos:Content) {

dateFilter = ${dateFilter}
}

categoryFilter = ${q(site).find('[instanceof JohannesSteu.Neos.News:Category]').get()}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be named categories as it contains a set of catgeories, not a filter itself

$nodeCategories = $node->getProperty("categories");
foreach ($nodeCategories as $nodeCategory) {
/** @var $nodeCategory Node */
if ($nodeCategory->getNodeData()->getProperty("uriPathSegment") == $categoryNode) {
Copy link
Owner

@johannessteu johannessteu Sep 22, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The check for a categoryNode shouldn't be done with the uriPathSegement but with the nodetype and identifer or path. With this implementation you could call the categroyFilter with an non category node

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how can I pass to $arguments the complete object of the node? I tried, but it will only send the node path as string. So I have to get the node again and compare the node itself again. Isn't this way slower because I have to get the node from the repo first? And by the way the get parameter looks kind of ugly with the node path, looks more clear with just the uriPathSegement

foreach($nodes as $node) {
/** @var $node NodeInterface */
$nodeCategories = $node->getProperty("categories");
foreach ($nodeCategories as $nodeCategory) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be renamed to $categoryNode

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$categoryNode already exists

} else {
$nodesWithCategorySet = [];

$categoryNode = $arguments[0];
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$categoryNode should be checked if it is an instance of Category

@@ -2,6 +2,9 @@
{namespace ts=TYPO3\TypoScript\ViewHelpers}

<f:section name="newsFilter">
<f:if condition="{categoryFilter}">
<ts:render path="categoryFilterTemplate" context="{categoryFilter:categoryFilter}" />
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

context variables should als be named categories

<ul class="news-categoryfilter">
<li class="headline">Themen / Kategorien</li>
<li><neos:link.node node="{node}"><span class="news-categoryfilter__category">Alle</span></neos:link.node></li>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also Translate VH for this

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed it

<li class="headline">Themen / Kategorien</li>
<li><neos:link.node node="{node}"><span class="news-categoryfilter__category">Alle</span></neos:link.node></li>
<f:for each="{categoryFilter}" as="filter">
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for each {categories} as category

<f:for each="{categoryFilter}" as="filter">
<li>
<neos:link.node node="{node}" arguments="{category: '{filter.properties.uriPathSegment}'}"><span class="news-categoryfilter__category">{filter.properties.title}</span></neos:link.node>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't access .properties on a a node within fluid as it slows down rendering a lot

templatePath = 'resource://JohannesSteu.Neos.News/Private/Templates/NodeTypes/NewsFilter.html'
sectionName = 'categoryFilter'

categoryFilter = ${categoryFilter}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be renamed to categories

@@ -35,7 +35,9 @@ prototype(JohannesSteu.Neos.News:NewsList) < prototype(Flowpack.Listable:ListNod
[email protected] = ${q(value).count() > 0 && q(value).removeImportantNews(respectImportant).get()}

# apply newsfilter if set
[email protected] = ${request.arguments.category != NULL ? q(value).filterByCategory(request.arguments.category).get() : value}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please prefix the argument with newsfilter as category is pretty much global and could also be used for something different

@johannessteu johannessteu changed the title [TASK] Filter by Category TASK: Add a category filter Sep 22, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants