2

I'm working on a site that uses a date slider to select members of the site by birthdate. I want to show the users by gender and between two "ages". For example: Male, between 40 and 50 years old. The selection on gender works perfect, but I can't seem to get the lowest age set. This is does work; with only the lower date set.

{% set dateRange = '<= ' ~ lower_date %}

{% set queryParams = {
        geboortedatum : dateRange,
        order :'lastName'
    } 
%}  

But once I set the upper age I've got an error.

{% set dateRange = '<= ' ~ lower_date ~ ' AND => ' ~ upper_date %}

{% set queryParams = {
        geboortedatum : dateRange,
        order :'lastName'
    } 
%}  

{% set leden = craft.users(queryParams) %}
{% set leden = craft.users(queryParams) %}

This gets this error:

Fatal error: Call to a member function getTimestamp() on a non-object in /chroot/home/deacteur/deacteursgilde.be/craft/app/helpers/DbHelper.php on line 597

Can anyone help me out here? I'm totally lost... Thanks a lot!!

3
  • 1
    I suspect it's going to come down to what the format of lower_date and upper_date are. Can you update the question with those?
    – Brad Bell
    May 12 '16 at 17:03
  • Also, isn't the operator wrong, shouldn't it be >=, not =>? May 13 '16 at 12:58
  • Our code now: {% set dateRange = '>= ' ~ upper_date ~ ' AND <= ' ~ lower_date %} {% set queryParams = { search: { query: geslacht_param_string, attribute: 'geslacht' }, geboortedatum : dateRange, order :'lastName' } %} {% set leden = craft.users(queryParams) %} {# a dump of the queryParams prints this: array(3) { ["search"]=> array(2) { ["query"]=> string(5) "vrouw" ["attribute"]=> string(8) "geslacht" } ["geboortedatum"]=> string(31) ">= 1946-06-13 AND <= 1965-06-13" ["order"]=> string(8) "lastName" } #} Without success, it won't pick the members between the range...
    – Jan
    Jun 13 '16 at 13:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.