Filter channel entries by category with nested condition - expressionengine

How can we filter channel entries like below:
{exp:channel:entries category="1&2&3&(5|6)"}
Is it possible to use '&' and '|' together?

Nested conditions isn't possible natively. Dandy Cat, a free plugin, will give you this exact functionality.
So for your example, you would do:
{exp:dandy_cat:entries categories=”(1&2&3)&(5|6)”}
....
{/exp:dandy_cat:entries]

Related

Specify both AND and OR conditions in ldap_access_filter

How do i add filter with both AND and OR condition in ldap_access_filter?
I have my ldap search filter as below with multiple groups. I now want to add one more condition where users need to be part of a primary group and then part of any mentioned groups in the filter. I have tried options in https://www.freeipa.org/images/c/cc/FreeIPA33-sssd-access-control.pdf but it didn't work.
ldap_access_filter = (|(memberOf=cn=DATA,ou=HADOOP,ou=APPLICATION_GROUPS,ou="ACCESS GROUPS",ou=GROUPS,dc=COMPANY,dc=CORP)......)
probably something like this:
(&(memberof=cn=primary_group)(|(memberof=cn=group1)(memberof=cn=group2)(memberof=cn=group3)))
example:
"(&(memberof=cn=localadmin,CN=Users,DC=company,DC=com)(|(memberof=cn=marketing,cn=users,dc=company,dc=com)(memberof=CN=Standards Share Access,CN=Users,DC=company,DC=com)))"

Kentico - Multiple Choice Dual List Form Control

I found this Multiple Choice Dual List (with Sort) form control and have a question about the sorting functionality. From the description, it looks like the sorting functionality only works if we have something like this CHARINDEX(','+CONVERT(varchar, ItemID)+',', ',1,3,2,5,4,') in the Order By field. I tested with a couple of items and saw that if I hard-coded the Order By as instructed, it worked. Is there a way / something to put in the Order By so that it accepts the (new) order of the items in the second (red) box - without hard-coding? THANK YOU!
My authors (the left box) are from a SQL query.
The WHERE statement of my Repeater is like this, if it's of any help:
'|' + '{%CurrentDocument.Authors#%}' + '|' LIKE '%|' + CONVERT(varchar, AuthorsID) + '|%' Everything is working; I just need that sorting functionality to work dynamically.
I think the easies way to achieve this would be implementation of some logic on the client with javascript/jquery.
That would be my tool. The example order by is meant to show kind of how it works, your order by would look like:
CHARINDEX(','+CONVERT(varchar,AuthorsID)+',', '{%CurrentDocument.Authors#%}')
Assuming that Authors is the field that has the multiselect with order form tool, and AuthorsID is the table's identity row.
Does that help?

Adding filter operators for Angular Formly generated fields

I need to add filter operators such as like "<", ">", "=", "like" before my field input. Is there a way to accomplish this?
I only need the operator value - my applications back-end will do the rest.
Something like this perhaps
{age:{value:25,filterOperator:"<"}}
You'll probably want to follow something like this example that allows you to put two fields next to each other using flexbox. Or if you have to use some other grid system, you might look at the bootstrap version

Is this the right way to filter channel entries using conditional variables?

Is this the most efficient way to filter a load of channel entries? I want to display entries that have no comments and that are not sticky. I'm using this code.
{exp:channel:entries channel="{segment_3}" status="open" orderby="date" disable="categories|category_fields|member_data|pagination"}
{if comment_total == "0" AND sticky == 'n'}
...
{/if}
{/exp:channel:entries}
Cheers
Lee
Using conditional variables, probably. But this will likely return lots more results than you need. Plus you won't be able to accurately use {count} (maybe not an issue for you, though).
Another approach which doesn't use conditional variables, but just goes straight after the results you want, and only the results you want, is to use the Query Module
{exp:query sql=
"SELECT title
FROM exp_channels
JOIN exp_channel_titles ON exp_channels.channel_id = exp_channel_titles.channel_id
WHERE exp_channels.channel_name = '{segment_3}'
AND exp_channel_titles.status = 'open'
AND exp_channel_titles.sticky = 'n'
AND exp_channel_titles.comment_total = 0"
}
<li>{title}</li>
{/exp:query}
This could get tedious if you needed to access a bunch of custom fields, but it is an efficient way to get the results you want.
Sticky is an available parameter on the entries loop, so you could filter at least that element in the entries loop itself by simply adding sticky="no", but comments, unfortunately, is not an available parameter, so Alex's suggestion may be the best option if your requirements are fairly simple. If you need access to a significant number of custom fields, however, it may be a bit tricky. So you'll have to decide what approach to take based on what you need within your loop.

Expression Engine - Is it possible for exp:channel:entries tag to have complex filters?

Coming from Codeigniter and new to Expression Engine, I am at a loss on how to do complex filters on the exp:channel:entries tag.
I am interested in this filters
status
start_on
stop_before
How do you do you implement filters for a complex condition like this?
(status=X|Y|Z AND start_on=A AND stop_before=B) OR (status=X AND start_on=C AND stop_before=D)
Is this even possible?
You can only use the search= parameter to search on “Text Input”, “Textarea”, and “Drop-down Lists” fields unfortunately. So you'd need to use the query module for this.
If you're just querying on those parameters you should be able to get the entry id's you need from the exp_channel_titles table, then use something like the Stash plugin to feed the entry_id's of the results into a regular channel entries tag. Yes it's nominally one more query that way but as EE abstracts the db schema fairly heavily the alternative is to get lost in a mess of JOINs.
So something like (pseudocode, won't work as is):
Get the entries, statuses are just a string in exp_channel_titles, entry_date is the date column you want - which is stored as a unix timestamp, so you'll need to select it with something like DATE( FROM_UNIXTIME(entry_date)) depending on the format of your filter data.
{exp:stash:set name="filtered_ids"}{exp:query sql="SELECT entry_id
FROM exp_channel_titles
WHERE status LIKE ...<your filter here>"
backspace="1"
}{entry_id}|{/exp:query}{/exp:stash:set}
Later in template:
{exp:channel:entries
entry_id="{exp:stash:get name="filtered_ids"}"
}
{!--loop --}
{/exp:channel:entries}
Yes it's a mess compared to what you're probably used to in pure CI, but the trade off is all the stuff you get for free from EE (CP, templating, member management etc).
Stash is awesome by the way - can be used to massively mitigate most EE performance issues/get around parse order issues
You can get a lot of this functionality using the search= parameter in your {exp:channel:entries...} loop.
It's not immediately clear to me how you'll get the complexity you seek, so you might end up resorting to the query module though.
If you're working with dates you might find the DT plugin useful.

Resources