CMS Development

jestlinbaum
Teilnehmer/-in

selectattr filter questions

lösung

I have the following code to filter rows in a DB table:

{% set table = hubdb_table_rows(1040830, queryparam) %}

After those rows are returned I have the following code to further list the results:

 

 

{% set easi_set_buildings = table|selectattr('catid','equalto','eset-std') %}

{% if easi_set_buildings == [] %}
    <!-- Do Nothing -->
{% else %}
    <h3>Headline</h3>
    {% for row in easi_set_buildings %}
        Do Stuff
    {% endfor %}
{% endif %}

This is working fine.

 

Here are my questions.

1. I tried using the following:

{% set easi_set_buildings = table|selectattr('catid','containing','eset-std') %}

and nothing happened.

Can I use the selectattr filter when referencing a multi select column (or a column that contains multiple values)?

 

2. Can I apply multiple "requests" to the selectattr filter... like:

{% set easi_set_buildings = table|selectattr('catid','equalto','eset-std' AND 'subcatid','containing','blah') %}

Any help is greatly appreciated.

 

Thanks!

 

0 Upvotes
1 Akzeptierte Lösung
Anton
Lösung
Trendsetter/-in | Diamond Partner
Trendsetter/-in | Diamond Partner

selectattr filter questions

lösung

@jestlinbaum my bad.

Had copied only a part from the link 🙂

 

Here's the complete one

 

If this shouldn't work - search for "HubDB filtering by custom module" by "Anton"(me) in this board. 🙂

 

 

Please let me know, if this works for you

 

 

 

regards

Anton

Anton Bujanowski Signature

Lösung in ursprünglichem Beitrag anzeigen

5 Antworten
ben-duchy
Stratege/Strategin

selectattr filter questions

lösung

I'm trying something similar but with dates. Any idea what I'm doing wrong?

{% set num_meetings = table | selectattr ("meeting","equalto","28/05/2021") | datetimeformat('%e/%m/%Y') | length %}

 

{{ num_meetings }} <!-- number of meetings for this date should be displayed but I can't get it to work -->

0 Upvotes
Anton
Trendsetter/-in | Diamond Partner
Trendsetter/-in | Diamond Partner

selectattr filter questions

lösung

Hi @jestlinbaum ,

have you tried to concatenate the both options?

 

I've had a project last year where I had to concatenate multiple HubDB column entries to one filter... the concatenate operator did it's job 🙂

 

You can find the thread here

 

 

 

 

 

Anton Bujanowski Signature
0 Upvotes
jestlinbaum
Teilnehmer/-in

selectattr filter questions

lösung

@Anton  thanks for the response!

The link you left gives me this:

 

"The page you are trying to access was not found. Please check your URL for typos and try again."

 

Would love to see it. 

Are you referring to the Join filter?

 

Thanks again.

0 Upvotes
Anton
Lösung
Trendsetter/-in | Diamond Partner
Trendsetter/-in | Diamond Partner

selectattr filter questions

lösung

@jestlinbaum my bad.

Had copied only a part from the link 🙂

 

Here's the complete one

 

If this shouldn't work - search for "HubDB filtering by custom module" by "Anton"(me) in this board. 🙂

 

 

Please let me know, if this works for you

 

 

 

regards

Anton

Anton Bujanowski Signature
jestlinbaum
Teilnehmer/-in

selectattr filter questions

lösung

@Anton  yes, I think this is what I'm looking for.

 

Thank you so much!

0 Upvotes