New answers tagged

3

The entry variable is an instance of craft\elements\Entry. Most of the attributes you are going to be interested in are either properties of the class or customf fields. Class properties All entries have properties like a the title, id, postDate, slug, authorId, etc. You can find them in the class reference for the Entry class. Check out the base Element ...


1

The template will be rendered with an element variable which you can use to display fields and other properties of the given element. See the info displayed in the settings once you add it to the field layout: In general, here's useful debugging method to find out what variables are available in a given template: {% dd _context | keys %} The _context ...


1

The craft.systemSettings variable was been deprecated as of Craft 3.1.0. Here's how to do it in Craft 3.1.0+: {{ craft.app.projectConfig.get('email').fromEmail }} Other email settings such as replyToEmail and fromName are also available via craft.app.projectConfig.get('email'). Alternatively, email settings can be accessed via the App helper class: {% set ...


2

It depends on what extension you're using for the Twig syntax highlighting and which language the file is set to use in VS Code. Extensions I use Twig Language 2 – this extension can handle the code you posted without errors. It also comes with snippets, formatting and everything you need to work with Twig and Craft. I can reproduce this error only with Twig ...


2

You can't put PHP code into Twig, and there's no straightforward way to write custom DB queries in Twig. That's by design – Twig is a templating language, not meant for custom queries or processing. Instead, you should provide a service object with utitily methods that you can call from Twig. Depending on your use-case, you can accept parameters (for example,...


Top 50 recent answers are included