Skip to content
Snippets Groups Projects
Commit f2e97d51 authored by Torsten Oppermann's avatar Torsten Oppermann
Browse files

[TASK] Adding filter partial, js

parent 62b81c43
No related branches found
No related tags found
1 merge request!5Feature 5 2 0
......@@ -56,11 +56,12 @@ class ListByCategoryController extends AbstractController {
* Renders the news list of a category
*
* @param array $newsMetaData
* @param array $newsFilter
* @return void
* @throws \InvalidArgumentException
* @throws \TYPO3\CMS\Extbase\Persistence\Exception\InvalidQueryException
*/
public function indexAction(array $newsMetaData = []) {
public function indexAction(array $newsMetaData = [], array $newsFilter = []) {
$filterByCategories = FALSE;
$categoryUids = GeneralUtility::intExplode(',', $this->settings['categories']);
$tagUids = GeneralUtility::intExplode(',', $this->settings['tags'], TRUE);
......@@ -75,6 +76,9 @@ class ListByCategoryController extends AbstractController {
$categoryUids = [(int) $GLOBALS['TSFE']->id];
}
$tags = $this->tagRepository->findAll()->toArray();
$this->view->assign('tags', $tags);
$categories = [];
foreach ($categoryUids as $categoryUid) {
$categories[$categoryUid] = $this->categoryRepository->findByUid($categoryUid);
......@@ -117,7 +121,7 @@ class ListByCategoryController extends AbstractController {
$nextPage = $currentPageBrowserPage + 1;
if ($nextPage <= $numberOfPages) {
GeneralUtility::_GETset(['tx_sgnews_pagebrowser' => ['currentPage' => $nextPage]]);
$this->indexAction($newsMetaData);
$this->indexAction($newsMetaData, $newsFilter);
return;
}
}
......
<f:form id="sgnews-filter" action="{action}" controller="{controller}" method="get" objectName="newsFilter">
<label for="filter-categories">
<f:translate key="frontend.filter.category" />
</label>
<f:form.select class="sgnews-select form-control" multiple="0" size="1" value="{selectedCategory}"
property="category" optionLabelField="title" optionValueField="uid" options="{categories}"
id="filter-categories" prependOptionLabel="" prependOptionValue=""/>
<label for="filter-tags">
<f:translate key="frontend.filter.tag" />
</label>
<f:form.select class="sgnews-select form-control" multiple="0" size="1" value="{selectedTag}"
property="tag" optionValueField="uid" options="{tags}" id="filter-tags"
optionLabelField="title" prependOptionLabel="" prependOptionValue=""/>
</f:form>
<f:layout name="Default" />
{namespace sg=SGalinski\SgNews\ViewHelpers}
<f:section name="main">
<div id="sgnews-newslist">
<f:render partial="Filter" arguments="{controller: 'ListByCategoryController', action: 'index', categories: categories,
tags: tags, selectedTag: selectedTag, selectedCategory: selectedCategory}" />
</div>
<section class="content light-bg">
<div class="container">
<f:for each="{categories}" as="category">
......@@ -26,7 +31,9 @@
</f:for>
</ul>
<f:format.raw><sg:pageBrowser numberOfPages="{numberOfPages}" /></f:format.raw>
<f:format.raw>
<sg:pageBrowser numberOfPages="{numberOfPages}" />
</f:format.raw>
</div>
</section>
</f:section>
/***************************************************************
* Copyright notice
*
* (c) sgalinski Internet Services (https://www.sgalinski.de)
*
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
'use strict';
import $ from 'jquery';
/**
* javascript for submitting the form when filtering
*/
export default class CategoryFilter {
/**
* Kicks things off
*/
constructor() {
$('#sgnews-newslist').on('change', '.sgnews-select', this._filterNewslist);
}
/**
* Filter for the newslist, simply apply the form
*
* @private
*/
_filterNewslist() {
$('#sgnews-filter').submit();
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment