Questions tagged [filter]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1 vote
2 answers
24 views

Range filter doesn't accept variables

How do I pass variables into the range filter from a static supertable field? {% for item in variants.b2bProductQty %} {% set start = item.selectRange.cellStartInteger %} {% set end = item....
KSPR's user avatar
  • 3,776
1 vote
1 answer
29 views

How to control string translation through camel to kebab filters and back again (this is a tip not a question)

Putting this here in case anyone finds it useful. Strings like 'ABC thing' when pushed through camel and kebab filters can cause unexpected issues. For example… {% set str = 'ABC thing' %} {% set key =...
Jonathan Schofield's user avatar
0 votes
0 answers
22 views

GET Checkbox Value to the Query (Entries Field) [duplicate]

I am writing my first post because I am stuck and cannot move forward. I need a filter that filters by "Entries Field." The selection is done through a form + checkbox. I also get the ID of ...
Tomka84's user avatar
1 vote
1 answer
149 views

Working with "money" values

It's the first time I have been using a "money" field and don't really know how to use it. The docs don't tell much about it so I ask for help here. To get the value including a currency ...
obs's user avatar
  • 487
1 vote
1 answer
34 views

Customizing reports that can be exported to Excel

Can I export the orders to a csv file? I'd like to know what our customers purchased as some of our sales are from development and others from the shop and I need to separate these totals for ...
Valerie Newton's user avatar
1 vote
1 answer
79 views

How to set up webhooks individually for each site in multi-site configuration with many customers?

The current issue is that I have multi-site setup, where are many different sites in a single Craft instance, e.g., I have 10 websites from 10 customers, when one customer updates his website I want ...
Vladimir Andrianov's user avatar
1 vote
1 answer
58 views

How to compare entries based on color?

Currently working on a website with a large amount of artworks. Each of these artworks contains a number of labels that links to a color (hex and RGB). I want to try to generate a list that retrieves ...
Jay V's user avatar
  • 73
1 vote
2 answers
99 views

Translate only the default twig value (Nesting twig filters)

Is it possible to write this as a one-liner? {% if craft.entries.section('mypage').one() != null %} {{ craft.entries.section('mypage').one().title }} {# If title is provided - use, but don't ...
PWL's user avatar
  • 157
1 vote
2 answers
150 views

Hiding categories in real time with Sprig in a faceted search

I've built three buttons with checkbox dropdowns that display categories that filter the content below based on categories. I am currently using the relatedTo function to only display the categories ...
Elektra Murphy's user avatar
1 vote
1 answer
83 views

Difficulties to setup a Filter class

This question is following this one: Where to implement Craft Webhook FilterInterface. I'm trying to implement a Craft Webhook FilterInterface but failed to load it. Below is the content of my setup, ...
Romain P.'s user avatar
  • 1,798
1 vote
1 answer
137 views

Twig filter country_name in craft CMS

Craft CMS doesn't have TWIG filter country_name. Even by default country name filter package is not available in twig. We need to install the corresponding package. https://twig.symfony.com/doc/3.x/...
Parthiban's user avatar
1 vote
1 answer
363 views

Filter entries based multiple category groups

This is related with Split categories by levels / List categories merged by name which I explain more on detail there, after that I take the suggestion of create separate category groups, so: I have ...
user15280052's user avatar
2 votes
1 answer
149 views

Fixing a YouTube regex in a replace filter

I need to take the dominant YouTube URL schemas and convert them into a YouTube embed URL of the form: https://www.youtube.com/embed/VIDEOID I know there are technically loads of possible YouTube URL ...
Jonathan Schofield's user avatar
1 vote
1 answer
1k views

Search on multiple custom fields with a query parameter

I would like to use a query term for multiple fields according to their fields' handle in Craft cms 3.5.x, but unfortunately only for field title that works correctly, while for the other fields i get ...
asimkon's user avatar
  • 111
0 votes
0 answers
88 views

Split categories by levels / List categories merged by name

I have a scenario where I need category levels (4 levels) split in different sections of the page, also some categories have the same name, I explain: I need to list entries based on a category group ...
user15280052's user avatar
1 vote
1 answer
150 views

get next entry with entry.getNext(), based on a multiple category filter

I have a section, where i display a list of entries from a structure. The section is an overview page, where the entries are listed with a picture and title. If the user clicks on an image, a detail (...
Henrik's user avatar
  • 383
1 vote
1 answer
759 views

Element API: Get Entries Related to Category with Query Parameter

I'm using the Element API Plugin to create an API, with which I want to get entries related to one category, but dynamically with the category set in the Url. What I have so far in the config/element-...
Malte's user avatar
  • 215
1 vote
1 answer
557 views

Sprig - Filter entries by custom field checkbox values, separate values as well as all values

I am having a question regarding Sprig. I do want to filter my entries for values that are defined in a dropdown field (example below is simplified). It does work to the point where I want to filter ...
HendrikEng's user avatar
  • 1,064
1 vote
2 answers
528 views

Twig Format Number Filter not working

Twig docs include a format_number filter, as of ver 2.12 My install shows Twig at ver 2.12.5, so should work, but throws a Twig Syntax Error: Unknown "format_percent_number" filter. This ...
Roi Agneta's user avatar
  • 1,413
1 vote
1 answer
244 views

Is there any way which does not remove Specific Html tags from the redactor editor using striptags only?

Is there any way to do it with striptags only or we have to use another filter?
Rakshita Solanki's user avatar
1 vote
1 answer
54 views

Craft Commerce: Filter completed orders based on a product category field

I know how to filter entries or products based on a category field with .relatedTo, but how can I filter completed orders based on a product category field? In this specific case, I have an overview ...
MetaMachine's user avatar
1 vote
1 answer
385 views

Filtering by lightswitch fields

Bit of an unusual one and sure must be missing something but know if we have a defined lightswitch field we want to filter against it can quite easily be done so like this: {{ craft.products().myField(...
Cole Henley's user avatar
  • 1,741
1 vote
1 answer
71 views

if entry has specific category, show specific html block

I have entries, which can have several categories. These categories are in different categorie groups. Now if i show an entry page, i want to display i certain html block based on a specific category, ...
Henrik's user avatar
  • 383
0 votes
0 answers
85 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 ...
4midori's user avatar
  • 626
1 vote
1 answer
137 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']) ...
user10961's user avatar
2 votes
3 answers
1k 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'...
Sandwich's user avatar
  • 626
1 vote
1 answer
108 views

How to display decimals as fractions?

Is there a twig filter to display decimal values as fractions?
ponies's user avatar
  • 387
1 vote
2 answers
412 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 ...
Jake1293's user avatar
  • 149
1 vote
1 answer
76 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 ...
Jake1293's user avatar
  • 149
2 votes
0 answers
167 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 ...
Josh Coady's user avatar
1 vote
1 answer
67 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 ...
Martin's user avatar
  • 1,203
1 vote
1 answer
223 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 ...
Justin Kendall's user avatar
2 votes
1 answer
273 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')...
Rakhi Vijayan's user avatar
1 vote
2 answers
84 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 ...
Chrisl2310's user avatar
1 vote
1 answer
99 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 ...
John Johnson's user avatar
1 vote
0 answers
92 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 ...
kmgdev's user avatar
  • 1,169
0 votes
1 answer
74 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 ...
Christopher Kennedy's user avatar
1 vote
1 answer
292 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 ...
Jessica Talzor's user avatar
1 vote
1 answer
36 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' }, { '...
cannon303's user avatar
  • 309
1 vote
2 answers
969 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 ...
g1un's user avatar
  • 81
4 votes
1 answer
944 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()...
Ben Croker's user avatar
  • 7,266
1 vote
1 answer
116 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 ...
Kevin's user avatar
  • 33
1 vote
1 answer
37 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|...
Людмила Петчик's user avatar
1 vote
1 answer
736 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 ...
mateostabio's user avatar
1 vote
1 answer
100 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 ...
user9247's user avatar
1 vote
1 answer
35 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....
sarah3585's user avatar
  • 899
1 vote
2 answers
332 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|...
Roi Agneta's user avatar
  • 1,413
4 votes
1 answer
1k 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 ...
Urs's user avatar
  • 639
5 votes
1 answer
1k 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 ...
Hassan Mahmood's user avatar
2 votes
1 answer
263 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 ...
Dan Zuzevich's user avatar