Created
February 10, 2021 21:09
-
-
Save ostark/f2560ae0664c4cefbd1c3d627bd445d1 to your computer and use it in GitHub Desktop.
lightweight entry queries without custom fields
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Remember old Field service | |
{% set fieldService = craft.app.get('fields') %} | |
// Overwrite the service in the container (it will be called later by the EntryQuery) | |
{% do craft.app.set('fields', 'modules\\NoFields') %} | |
// Execute the query | |
{% set result = craft.entries().all() %} | |
// Restore the original state | |
{% do craft.app.set('fields', fieldService) %} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace modules; | |
class NoFields extends \craft\services\Fields | |
{ | |
public function getAllFields($context = null): array | |
{ | |
return []; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is a hack to avoid bloated results, if you don't need them, e.g. when displaying Structures with Entries that have tons of fields, but you need the title only.
Why bother?
Error 1038 Out of sort memory, consider increasing sort buffer size