Questions tagged [filter]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
1answer
7 views

Help with correct syntax regarding multisort please

Hi hoping for a quick resolution on this as a lot of scripting relies upon it. I have an array: {% set furniture = [ { 'name': 'chair', 'price': '100' }, { '...
1
vote
1answer
40 views

Arrow functions in twig or craft cms

I tried to use reduce function in template, but got error. It seems twig/craftcms can not work with such functions. Reduce function docs: https://docs.craftcms.com/v3/dev/filters.html#reduce My ...
4
votes
1answer
86 views

How to order or filter entries by their author's custom field?

Is it possible to order and/or filter all entries from a section whose author has a custom field value that is set to "X"? Below is the starting code. in Twig: {% set elementQuery = craft.entries()...
1
vote
1answer
24 views

Grouping entries and ordering by section

Im grabbing entries from two sections and displaying them using the group filter. {% set entries = craft.entries().section('extendedEvents, festivalEvents')%} {% set allEvents = entries %} {% set ...
1
vote
1answer
22 views

How I can sort my entry that belong to 3 section on date?

{% set blog = craft.entries.section('blog').all() %} {% set news = craft.entries.section('news').all() %} {% set caseStudies = craft.entries.section('caseStudies').all() %} {% set allEntries = blog|...
1
vote
1answer
81 views

Filter Entries by Category fields & refresh URL and list with AJAX

I'm finding myself stuck with filtering entries that are related to categories using a category field. I'm looking to build a sub-navigation on a page, where I can select from a select field or from a ...
1
vote
1answer
27 views

Filter entries by other entry

There's a section called locations and another called vacancies. In vacancies the admin can assign a location entry to a vacancy. On the careers overview page we want to display selected vacancies ...
1
vote
1answer
22 views

A-Z filter menu - limiting output to one when there are multiples

I have a A-Z menu to filter entries by their first letter. <ul class="directory-letters"> <li class="all current" data-filter="all">ALL</li> {% for entry in craft.entries....
1
vote
3answers
71 views

Syntax for Multisort Filter

I am trying to use the new multisort filter to sort an array in reverse order using a date key, but can't seem to figure out the correct syntax. Here is what I have: {% for rides in allRides|...
2
votes
1answer
120 views

Alphabetical index for a list of entries

I would like to build an alphabetical list of craft entries, but group them by the initials of one field of each entry. Thus, getting some kind of alphabetical index, like A Apples Ananas B Beer ...
3
votes
1answer
247 views

Filtering multiple categories with URL queries

I am trying to filter using categories. I have to filters type and size, in the url. /products.html?size=medium,large&type=polo-shirt,jeans In my template, I am doing the following {% set sizes ...
2
votes
1answer
78 views

Craft 3 Docs Group Filter Not Working

I am attempting to replicate the example from https://docs.craftcms.com/v3/templating/filters.html#group However, I am unable to access the {{ year }} in the first for loop inside the h2 element. It ...
1
vote
2answers
81 views

Filter Sprout Form entries throwing error

Based on this very helpful question I'm trying to filter the display of Sprout Form entries based on the value of a form field. For example, my form handle is 'reportHazardDeficiency' and my field ...
1
vote
1answer
110 views

Group Sites by Groups

We have many country websites on different continents. In the CP we group the sites, where the group has the name of the continent. Now we want to group the sites in the templates in the same way. I ...
1
vote
0answers
59 views

Filters using multiple query strings with pagination and Craft Commerce

I want to build the ability for the user to be able to filter by certain categories when browsing an existing category. As well as this I would like the user to be able to control the ordering of ...
1
vote
1answer
38 views

Why are my entries disappearing when {% if category | length %} is added?

Editing an index page that displays all entries within a structure. Everything displays fine. I add a category to a few entries and add {% if category | length %}and everything disappears as if no ...
1
vote
1answer
248 views

Filter entries by ajax to controller

Short story: I need your help sending value from dropdown selection as data to controller so my div updates with the filtered entries based on the selection. Long story and code: I have a listing of ...
0
votes
1answer
118 views

How to output a Rich Text Link to an Entry as a tooltip?

I have a Glossary channel on my site, with Term and Definition fields. I would like Terms to display their definitions throughout the site...whenever so assigned by the content editor. I currently ...
1
vote
0answers
30 views

Commerce filter with width, height and length with tolerance

Hope you guys can help. I need to create a search feature on a craft commerce site that will allow the user to search for products in this principle: Product Type Width +- value height +- value ...
3
votes
2answers
537 views

Trimming lastSegment from a URI trims that PLUS the last number of the previous segment

I am fairly new to twig and templating with Craft (and I have inherited this code, so that makes it even more fun). I have a calendar page that lets you filter the events in the calendar based on a ...
2
votes
2answers
155 views

How to pull the first block of its kind from a Matrix?

This is a news feed with a title, image and short blurb beneath. The entry content is built with the Matrix. An entry can be made up of a single 'textEditorBlock' or multiple 'textEditorBlock'. I ...
1
vote
1answer
673 views

Filtering Search Results by Category

I'm currently trying to filter my search results by category, I've been following this tutorial but cannot get it to work. It keeps not adding on the category parameter, but instead just replaces the ...
1
vote
1answer
64 views

If no blog entries, show something else

I'm having a bit of trouble showing a message if there's no entries in my blog. I tried the length filter but my empty message wont show: {% for entry in craft.entries.section('volunteerPosition')....
2
votes
2answers
550 views

Convert characters to Ascii

Is there a twig filter to encode special characters like umlauts: {{ entry.title | filter }} Datensätze & Karten Which then should result in: datensaetze-karten Basically what '...
1
vote
1answer
82 views

|replace filter is matching too many characters

I'm looking to format out image tags from a string using the |replace filter. The behavior I'm looking for is to give it a string like this: <img src="test.jpg"><p>some text</p><...
1
vote
1answer
87 views

Filtering out section entries

I'm quite new to Craft CMS and have takeen over an application (using Twig templates). I'm trying to run a filter but not having much joy so maybe I might get some help! So, there is a people ...
2
votes
1answer
180 views

Load entries based on category field value while multiple categories are selected

I have an activity calendar (more like a weekly schedule) which filters per day and per category. Because there are so many activities I can't just load them all in at once so I use some sort of Ajax ...
0
votes
2answers
98 views

Exclude entries by array of authors from ElementCriteriaModel

I'm trying to get a list of entries of a certain section, however I'd like to exclude certain users that are defined within a field of the entry. The users to exclude from the query are fetched like ...
0
votes
1answer
108 views

Sanitize front-end entry form field

If I'm enabling a user to post to Craft using the front-end entry form, is there a way that I can sanitize the title of a post? I'm looking to apply AP formatting to titles. I know Stephen has a ...
2
votes
2answers
235 views

Grab first <img> or <img> src from Rich Text field

I've had the unfortunate task of importing thousands of entries in to Craft from Worpdress. Each of the entries has a Rich Text field and within the first couple of paragraphs there is an image. I ...
1
vote
1answer
76 views

How can I let the user activate a particular SuperSort filter

***I have just realised I am mixing up my filtering and sorting. I have amended the question to try and make it a bit clearer. I'm trying to use SuperSort plugin to run different filters, but I'm ...
1
vote
2answers
205 views

Filtering dynamic criteria with AND

I have a form that is set up to include multiple values with checkboxes. I pass all those values into an array {% set specsQuery = craft.request.getParam('specs') %} {% set productSpecsCategory = ...
1
vote
0answers
105 views

Need help with filtering entries by a custom field using ajax with pagination

I'm fairly new to CraftCMS and am stuck with a little filtering issue. I'm trying to filter a page of entries by a custom field. I'd like to use Ajax so there is no page reload. Here's how I have the ...
2
votes
1answer
644 views

Entries related to BOTH categories

I've got categories setup like this (Parent & Children): Type Tops Dresses Pants Colour Black Red Yellow When I use this in a category filter and choose Dresses and ...
2
votes
2answers
304 views

Trouble getting entries after a certain date

I have a bunch of entries with field eventStartDate and eventEndDate. First I set the date {% set fwd = entry.eventStartDate|date_modify('+30 min')|date('c') %} When I output the value of fwd, ...
1
vote
1answer
157 views

How to use the same category group as a filter on multiple channel sections?

I have two channel sections, each with only their own entry types. I've added the same category group field to both. I'd like to filter each channel's list of entries by the same category group. So ...
1
vote
1answer
243 views

Search entries by location or name

I have a page that lists all of the property developments of my client, and am able to show the lists of the categories in the dropdown fields, but I can't work out how to get them to actually change ...
2
votes
2answers
1k views

How to filter entries based on Tags

I am working on a site that requires a filter option based on tags. Each entry will have two sets of tags (e.g., colors and shapes) {% for tag in craft.tags.group('colorTag') %} {% for tag in craft....
1
vote
1answer
448 views

Filter entries by multiple field ranges

I am trying to filter entries based on multiple field value ranges. For example: All entries where my customField (type: number) is between 0 and 10 OR 20 and 25. It's straightforward to filter by ...
3
votes
2answers
274 views

Using user-selectable timezones to show localized post dates

In my user profiles, I have a text field where the user's timezone is set, in the standard America/New_York format. Craft's timezone is set to New York, and the server's timezone is set to UTC. I'm ...
1
vote
1answer
241 views

How to set the commerceCurrency filter in an European style

Using commerceCurrency filter from the Craft commerce plugin, how can I add the currency name after the price instead of before the price, and drop the zeros when not necessary ? For example : {{ ...
4
votes
1answer
300 views

multi-select OR values to filter entries

preface: i'm new to craft so may get terminology incorrect basic idea: i would like to show entries of a particular channel which have multi-select field values which intersect with another set of ...
1
vote
1answer
279 views

Get all images from a section

I want to get all images from the section projekte which are bound to the asset field bild I then want to fiddle around with .limit() and maybe random filters. So I grabbed all images like described ...
1
vote
0answers
110 views

Combined searches and filters with a Matrix

I am fairly new to Craft but have managed to build a combined search feature that users can filter from dropdowns. I used this as a guide and it works great: https://webstoemp.com/blog/combined-...
2
votes
1answer
330 views

Count all unique values

We are building a family community website with more than 600 members all over the world. In craft.users we have added many fields and one of them is country. We want to display and count all ...
2
votes
2answers
136 views

How to calculate average age members

We are building a family community website with 600+ members. One of the gimmicks will be some stats, like average age all members. Is there a smart way to calculate this?
2
votes
1answer
130 views

How to shorten 'craft.request.getUrl()' with the shortener plugin?

How can I use the shortener plugin to get and shorten the current URL? I've tried both twig and plugin methods shown in the docs, but the twig method outputs the FULL url, and the plugin method doesn'...
1
vote
1answer
81 views

Group by day does strange exeptions

I have a list of forms which I want to sort by day: {% set groupVerbund = 'datum.day' %} {% set allSubmissions = craft.amForms.submissions({ formHandle: 'reservation', limit: null}).find() %} {...
2
votes
1answer
167 views

Filter syntax for Dimensions & Weight?

Is there comparable syntax to display dimension and weight filter settings from Commerce similar to those for currency eg: {{ variant.price|currency('CAD') }}? Couldn't see any info on this in the ...
2
votes
1answer
364 views

Filter results after searching

Is there a kind of “search in results after you retreived all entries” thing? Thing is: I have this query: craft.entries.section('players').limit(null) I want to show all entries where playerPosition ...