Questions tagged [filter]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
0answers
24 views

Still no way to filter by category in Control Panel?

I'm wondering if, with the release of Craft 3.5, there is a way to filter by category in the control panel. I see this request goes back several years. The only workaround I can find is to use a ...
1
vote
1answer
15 views

Filter users: in group AND not in other group

Please could you advise on how to filter a user query, so that users from Group A are included, but not if they are also in Group B? {% set vnp_users = craft.users .group(['groupA', 'not groupB']) ...
0
votes
0answers
20 views

Filter Entry Query by Category

I'm making a staff page. The entries are in the section 'people'. There are four types of staff - leadership, wardens, staff, safeguarding - so there is a category field for each 'staffCategory'. That ...
2
votes
3answers
111 views

How do Twig filters interact with concatenated strings and shorthand “if-else” ( `var ? true : false` ) strings?

If I am outputting content like this: {{ entry.maxWidth|length ? entry.maxWidth ~ 'px' : 'unset' }} ...and I want to apply the |raw filter to the output (nevermind if it makes sense in this case; it'...
1
vote
1answer
21 views

How to display decimals as fractions?

Is there a twig filter to display decimal values as fractions?
1
vote
2answers
49 views

How to filter entries by multiple checkbox field types

I've set up checkbox fields for photos in a photo gallery called "photoColor", "photoSubject", and "photoSize", all of which contain a bunch of options. On the gallery ...
1
vote
1answer
47 views

Ajax request returns code instead of result of the query (solved)

I'm trying to answer my own question in this post Basically, I have a bunch of checkboxes in multiple categories and when clicked, I want to use Ajax to filter the results and show them on the same ...
0
votes
0answers
13 views

How to search/filter in CP by date range?

Is there a way in the control panel to list all entries with a date field between two dates? For example, last updated between 12/16/2019 and 2/15/2020. Interested in doing this for both automatic ...
1
vote
1answer
16 views

Showing Entries based on an Entries Field but also showing a slug in the url

I have a Channel 'Articles' with an Entries field which is linked to entries in 'Staff Members' channel. This is so that articles can be assigned to different members of staff. I have the generic ...
1
vote
1answer
30 views

How to create a category filter for a portfolio site?

I want to create a category filter similar to this website http://www.mypoorbrain.com/ (just a random website i found with the desired effect). Basically I want the categories to be displayed ...
1
vote
1answer
25 views

How to search based on a Multi select category field in Craft 3?

I have a blog section with multi select categories. I want to filter all the blogs based on that multi select categories in the website. When I tried .search('category:ui-ux OR category:web-designs')...
1
vote
2answers
51 views

Correct Limit for Entries with IF statements

I have content on my site that can't be shown in some countries and requires a basic level of geo-targeting, based on the users profile and not by any form of IP geo-targeting. I have set up an ...
1
vote
1answer
43 views

Grouping entries by a custom date conditional

I'm looking to group entries based on a condition between two custom date fields and the current date. I'm not even sure this is possible, but this is how it would appear visually: Happening Now ...
0
votes
0answers
22 views

Ajax loading for filter based on categories in Craft 3

I have a page with blog listed with pagination using craft paginate. {% paginate craft.entries.section(['blog']).orderBy('postDate desc').limit(15) as pageInfo, entryTemplates %} Now I am need of ...
0
votes
0answers
11 views

Sort entry query by their table of values if said values are in a separate array of values

Morning (in the UK at least) - I'm trying to sort/order/filter an entry query by an array of values. The array is a list of IDs (e.g. [2,7,8]), and inside each entry is a table with a list of IDs that ...
1
vote
0answers
20 views

Search if Super Table Field Has Rows

I have a section with a super table field, and I only want to display entries in that section if the super table field has rows (so basically a "not empty" search). How do I do this? I tried using the ...
0
votes
1answer
33 views

Is it possible to import the content of a rich text field into matrix using FeedMe without parsing reference tags to entries/assets?

Currently I have content that I’m trying to migrate from a single rich text field into a rich text field living in a Matrix content builder. Migrating most of the content is fine, but I would like to ...
1
vote
1answer
63 views

Does Craft automatically sanitize user input?

Can I rely on Craft to clean user input, is safe to save the following data like in the below example function, if not, what is the Craft best practice for cleaning(making it safe) user input? public ...
1
vote
1answer
22 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
379 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
234 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
38 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
32 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
364 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
52 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
30 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
2answers
160 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|...
3
votes
1answer
331 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 ...
5
votes
1answer
635 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
181 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
103 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
218 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
87 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
52 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
339 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
168 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
38 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
878 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
287 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
937 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
92 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
734 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
103 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
101 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
205 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
120 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
138 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
294 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
78 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
262 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 = ...