kapelanmedien/km-eventnews-filter

Filter event news by organizer, location, date, categories and tags

1.0.0 2024-08-26 13:49 UTC

This package is not auto-updated.

Last update: 2024-12-03 13:14:38 UTC


README

This extension makes it possible to filter event news in the frontend by the following properties:

  • organizer
  • location
  • date from & to
  • categories
  • tags
  • sword

This extension is an adaption of EXT:news_filter

Requirements

  • TYPO3 10.4
  • news 9.x
  • eventnews 5.x

Usage

  1. Install the extension just as any other extension. Either use the Extension Manager or composer and composer require kapelanmedien/km-eventnews-filter.
  2. Select the action "list" in the news plugin and activate the additional checkbox "Enable filter"
  3. Select folders containing categories & tags.
  4. In order for filtering by organizer and location to work, the event restriction "Only events" must be selected.

TypoScript

The following TypoScript is required

plugin.tx_news.settings.demandClass = KapelanMedien\KmEventnewsFilter\Domain\Model\Dto\Demand

Templating

Add the following part to your List.html:

<f:form action="list" object="{extendedVariables.searchDemand}" name="search" class="news-search-form mb-3">
    <fieldset>
        <div class="mb-3">
            <label class="form-label" for="news-subject"><f:translate key="search-subject" /></label>
            <f:form.textfield id="news-subject" property="subject" class="form-control" />
        </div>

        <f:if condition="{extendedVariables.organizers}">
            <div class="mb-3">
                <label class="form-label" for="organizers"><f:translate key="organizers" extensionName="eventnews" /></label>
                <f:form.select
                        property="organizers"
                        id="organizers"
                        class="form-select"
                        options="{extendedVariables.organizers}"
                        optionValueField="uid"
                        optionLabelField="title"
                        multiple="multiple"
                    />
            </div>
        </f:if>
        <f:if condition="{extendedVariables.locations}">
            <div class="mb-3">
                <label class="form-label" for="locations"><f:translate key="locations" extensionName="eventnews" /></label>
                <f:form.select
                        property="locations"
                        id="locations"
                        class="form-select"
                        options="{extendedVariables.locations}"
                        optionValueField="uid"
                        optionLabelField="title"
                        multiple="multiple"
                    />
            </div>
        </f:if>
        <f:if condition="{extendedVariables.categories}">
            <div class="mb-3">
                <legend class="form-label"><f:translate key="categories" /></legend>
                <f:for each="{extendedVariables.categories}" as="category">
                    <div class="form-check form-check-inline">
                        <f:form.checkbox property="filteredCategories" value="{category.uid}" id="category_{category.uid}" class="form-check-input" />
                        <label class="form-check-label" for="category_{category.uid}">{category.title}</label>
                    </div>
                </f:for>
            </div>
        </f:if>
        <f:if condition="{extendedVariables.tags}">
            <div class="mb-3">
                <legend class="form-label"><f:translate key="tags" /></legend>
                <f:for each="{extendedVariables.tags}" as="tag">
                    <div class="form-check form-check-inline">
                        <f:form.checkbox property="filteredTags" value="{tag.uid}" id="tag_{tag.uid}" class="form-check-input" />
                        <label class="form-check-label" for="tag_{tag.uid}">{tag.title}</label>
                    </div>
                </f:for>
            </div>
        </f:if>

        <div class="mb-3">
            <label class="form-label" for="searchDateFrom">Date</label>
            <div class="input-group">
                <f:form.textfield type="date" class="form-control" id="searchDateFrom" property="searchDateFrom" />
                <label class="input-group-text" for="searchDateTo">-</label>
                <f:form.textfield type="date" class="form-control" id="searchDateTo" property="searchDateTo" />
            </div>
        </div>

        <f:form.submit value="{f:translate(key: 'search-start')}" class="btn btn-primary" />
    </fieldset>
</f:form>

Order categories, tags, organizers and locations

plugin.tx_news {
    settings {
        filterCategoriesOrderBy = title
        filterCategoriesOrderDirection = asc

        filterTagsOrderBy = title
        filterTagsOrderDirection = asc

        filterOrganizersOrderBy = title
        filterOrganizersOrderDirection = asc

        filterLocationsOrderBy = title
        filterLocationsOrderDirection = asc
    }
}