Hot answers tagged

3

Yes, the post you linked to is what you need to do. I don't know where your settings variable is set so you may need to adjust a bit but something like this should get you started: {# Start your element query #} {% set query = craft .entries() .section('purchases') %} {# Check if settings.userId, if so, apply it to the query #} {% if settings.userId ...


2

Assuming you can have multiple person blocks per entry (group), you could: Fetch your entries and eager-load the blocks and their entry to save some overheads {% set group = craft .entries() .id([100,200,300]) .with(['people.person:entry']) .all() %} Then build an array with each person.entry {# The array to store your person.entry #} {% set ...


2

Stumbled upon this looking to answer similar problem. You should be able to do this now without a plugin, using the multisort filter where you iterate through your profiles, e.g.: {% for profile in profiles|multisort(['profileLastname'],[SORT_ASC],[SORT_REGULAR]) %}


2

For Craft 3, after you get the ids you don't want (that would be an array), create your query to disregard those ids in the following way: {# omitIds = array of ids you want ommited #} {% set dontNeedIds = 'elements.id not in ('~omitIds|join(",")~')' %} {% set news = craft.entries.section("news").where(dontNeedIds).all() %}


2

There are a few different solutions for this. Personally my favourite is to switch on static caching in nginx, as it's a relatively quick and easy solution. Andrew has you covered on how to do that here: https://nystudio107.com/blog/static-caching-with-craft-cms If you're not using nginx, then a popular choice is the Blitz plugin: https://plugins.craftcms....


2

You could do this: {# Your date 2020-11 in atom format e.g 2020-11-01T00:00:00+01:00 #} {% set departureDate = craft.app.request.getParam('departure') | date("Y-m") | atom %} {# Your date + 1 month in atom format e.g 2020-12-01T00:00:00+01:00 #} {% set untilDate = departureDate | date_modify('+1 month') | atom %} {# Query between those 2 dates #} ...


1

You should be able to use the date string you get from your parametern without even editing it. {% set entries = entries.startsOn(craft.app.request.getParam('departure')) %} More information about querying on datefields can be found here: Date Fields | Craft CMS Documentation | 3.x


1

If you want live and pending entries, you would need to pass status to your query with the values you want (docs). query yourQuery { entries(section: "yourSectionHandle", status: ["live", "pending"]) { title } } Or if you want to use variables: query yourQuery($section: [String], $status: [String]) { entries(section: $...


Only top voted, non community-wiki answers of a minimum length are eligible