0

I have some more questions and I hope I don't waste your time .. I use EE3.4.7. and Calendar (EE3 version) .. this questions continues from here Custom field as a parameter

  1. Since custom field searching is not possible with calendar:events my problem is this: I would like to give the opportunity to user to search for events in a city in certain dates. Now the city can be either a text field or a category, and at the moment I have a category group with events categories (music, theatre, cinema etc.) Should I create another group with cities?

  2. Can the city be a Stash variable or Low variable in a search form? Can it work that way?

  3. Also, can Calendar work in combination with Tag? For example can the city be a Tag field?

  4. Can I make searches with sql queries on the database tables to solve the above problem?

  5. In the end would custom field searching be available as a custom solution and what would be that cost?

1 Answer 1

0

I think you could use Stash for this. Setting a list of your calendar event data and then using regex in Stash to filter based on your custom field.

{exp:stash:set_list
    name="cal_events" 
    parse_tags="yes"
}
    {exp:calendar:events
        channel="events"
        date_range_start="year-month-01"
        date_range_end="year-month-last"
        limit="20" paginate="both"
    }
        {!--set stash variable for field to search--}
        {stash:event_city2}{calendar:event_city2}{/stash:event_city2}

        {!--set other variables--}
        {stash:title}{calendar:title}{/stash:title}
        {stash:event_start_date}{calendar:event_start_date format="%F %j, %Y"}{/stash:event_start_date}
        {!--etc...--}
    {/exp:calendar:events}
{/exp:stash:set_list}


{exp:stash:get_list
    name="cal_events" 
    match="#Athens#"
    against="event_city2"
}
    {if count == 1}
        <h5>Field we searched: {event_city2}</h5>
        <h6>Total Results: {total_results}</h6>
    {/if}

    <ul>
        <li>Title: {title}</li>
        <li>Event Start Date: {event_start_date}</li>
        <li>etc...</li>
    </ul>
    <hr>
{/exp:stash:get_list}

You'll have to check the docs for Stash on using Match and Against parameters. (You might also flip it from my example, and use match against parameters on the set_list instead of get_list, only setting variables you need.)

Couple of things:

  • This may decrease performance, but saving the stash variable and re-caching when necessary may help. See Mustash for help with managing Stash variables.
  • If you try it and don't get the results you expect, try adding the parameter "output='yes'" to set_list tag to see what's being set in the first place.
  • I haven't tested the above at all. Woohoo!
7
  • thank you very much for your time ... have not tested it yet but i will give it a try and report back Commented Apr 10, 2017 at 14:51
  • Wowwww ... it seems it is working with an exception for image file ... i have an image file field {event_pic2} .. now i set it as a stash variable on the set_list but on the get_list i cannot get the small version of the file like src="{event_pic2:small}" ... i tried to set the small version on the set_list but it does not return anything ... so now it has to load the big original file ...any idea where the pagination goes? ... i match the city with the city in segment of url {exp:stash:get_list name="cal_events" match="#{segment_3}#" against="event_city2" } Commented Apr 12, 2017 at 21:50
  • If you don't set a variable in set_list, you won't have it available when getting the list (get_list). So you need to set the small image url in set_list. Try using the parameter output="yes" to see exactly the variables you are setting. For pagination, read up on the Stash docs to see how to handle (very similar to regular ee tags): github.com/croxton/Stash/wiki/… Commented Apr 12, 2017 at 22:11
  • Well ... problem solved .. {stash:event_pic2} {calendar:event_pic2:small} {/stash:event_pic2} on the set_list and src="{event_pic2}" on the get_list ... now a question ... how much heavier the code becomes with these stash variables from the performance point of view knowing that Solspace calendar is heavy by itself Commented Apr 13, 2017 at 16:10
  • and another one thing ... i have a header that displays how many events there are in this city for this daterange but it is above the part we were discussing above (i.e. outside the get_list) .. is there anyway to pass the values from the get_list to that part ? Commented Apr 13, 2017 at 17:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.