Hot answers tagged

3

You can configure the columns to display using the little cogwheel icon at the bottom (below the list of sections): This will open a modal window allowing you to select the fields you want to display in the table for each section. You can also rearrange the fields using drag-and-drop with the little handle icon to the left of the field name. As a sidenote, ...


3

I agree that any solution where you run a query and then conditionally render the result isn't very efficient. You can do this in SQL by using the where() condition. craft.entries .section('mySection') .where('content.field_field1 > content.field_field2') .all() Documentation on the where() condition can be found here.


2

I'm not aware of any straightforward way to remove that field from the Entry form. You might want to consider creating a small site module, adding some logic in an event handler to re-write/remove the contents of the expiration date as necessary?


2

The equivalent SQL would be something like SELECT * FROM players ORDER BY teamName IS NOT NULL DESC, postDate DESC; but I'm not sure how that would translate in a simple element query. It'd be something like: {% set players = craft.entries.section('players').orderBy('teamName IS NOT NULL DESC, postDate desc').all() %}


1

Not sure if this can be done in the shorthand syntax, but you can do this using Twig for the dynamic title format. The key is to use map to turn an array of entries into an array of titles and then join them. Something like this should work: {{ object.movies.all()|map(movie => movie.title)|join(', ')|default('No movies selected') }} Also note the default ...


1

I can see what you're trying to do here, and it's really not a great idea to be honest: Just to clarify for anyone else - we're not talking about "Entry Types" here - you're talking about the order of the fields as defined in the entry type's field layout. A client should not have access to alter this. Clients and future developers would not expect ...


1

I was able to get the field structure using the below code. {% for entryType in entry.section.entryTypes %} {% set fieldLayouts = entryType.getFieldLayout().getFields() %} {% for field in fieldLayouts %} {{field.blockTypes[0]}}<br/> {% endfor %} {% endfor %} outputs the handles like this header whyChooseUs whatWeDo whoWeWorkWith ourClients ...


1

I think you might be going about this the wrong way. Personally, I'd create a single Matrix or Super Table field and attach that to your home page single. This is far easier for your editors to maintain and doesn't require the entry type's field layout every time you want to rearrange content. However, to answer your question: What you're looking for is the ...


1

You'll have to query all matrixes in that field with that type first. With these results, you should then be able to query the entries that are relatedTo these results. You'll end up with {% set matrixes = craft.matrixBlocks() .field('matrixField') .type('video') .all() %} {% set entries = craft.entries() .section(['events', 'sessions']) ...


1

I believe this won't work the way you want it with a single query, especially with reliable performance. The problem is that you actually want 2 different sort criteria being combined. I would recommend you add an additional field just for sorting using this plugin: https://plugins.craftcms.com/preparse-field It allows you to use TWIG to prepare a value ...


1

I believe you're looking for this instead. Event::on( Entry::class, Element::EVENT_AFTER_SAVE, static function (ModelEvent $event) { $entry = $event->sender; if ($entry->status === 'disabled' && $entry->propagating && $entry->resaving && ElementHelper::...


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