5

Unfortunately, the answer differs pretty dramatically for native properties with "stable" column names and for Content, which (as of Craft 3.7.0) now contain a "suffix" that (in most any other case) is not a concern for developers. More on that in a moment. Titles For titles, it's as simple as using the .select() method native to the ...


3

Just to expand on the caveat regarding field suffixes in Craft 3.7+, I asked on Github what the recommended way to include field suffixes in a custom query is. Here's brandonkelly's response: The easiest way to do it would be to just hardcode the column name in your template. It won’t change between environments or anything. That said, it does feel kind of ...


3

Since you have two sections, you will need your two initial queries, however, in your example, although you are eager loading the children (with(children)), you are querying them a second time when doing page.descendants.all(). Because you are doing this for every parent, things are adding up and you are hiting this high query count and speed issue. First, ...


2

I've faced this a few times and solved it like this: {% set entries = craft.entries.section([ 'section1', 'section2', 'section3', ]).all() %} {# group the results by section handle #} {% set entriesGrouped = entries|group('section.handle') %} {# use this array to specify a manual order to be used when outputting the results #} {% set ...


1

Since posting the original question, I have also solved this like so: {% set aboutPages = craft.entries.section(['about']).all() %} {% set newsPage = craft.entries.section('newsIndex').one() %} {% set aboutNavigation = aboutPages|merge([newsPage]) %}


1

Thanks to help from Ryan on the Discord group, I found an anwser. This being… // Call the channel {% for serviceEntry in craft.entries.section('service').limit(3).all() %} <h1>{{ serviceEntry.title }}</h1> <p>{{ serviceEntry.excerpt }}</p> <ul> // Call the block within the loop {% for block in serviceEntry....


1

Yes, it is possible, I used to do this for simple tasks years ago, before the Element API plugin was released, and now there is the GraphQL API, of course. But it really only is practical for pre-determined queries, otherwise you should probably use one of the solutions above or a custom module/plugin. Here is a trivial example: {# Fetches entries with ...


1

Craft has changed since the above answer was given. The now object must be a part of the string, rather than concatenated as an object. so instead of: {% set futureEntries = craft.entries.section('events').dateAndTime('>= ' ~ now) %} use: {% set futureEntries = craft.entries.section('events').dateAndTime('>= now') %}


1

Craft 3.7.15 onwards you can use is array twig test. More info https://github.com/craftcms/cms/blob/develop/CHANGELOG.md


1

For comparing strings and negating the result I'm using the following construction: {% set is_training = course_type == 'training' %} ... {% if not is_training %} ...


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