2
votes
Get section handle of an entry inside of an EntryField
If the linkedEntry field is empty, then category.linkedPage.one() will evaluate to null, so you should always add a condition to check that a value exists before calling a method on it.
{% set ...
1
vote
Updating/replacing query string parameters with twig
So I'd approach it something like this:
{# Get the incoming query params #}
{% set params = craft.app.request.queryParams %}
{# Change/add the params we need to #}
{% set params = ...
1
vote
Accepted
How to use twig macro inside controller?
Not directly, macros can only be included from within Twig. But you can create a simple wrapper template and render that:
{# my-macro.twig #}
{% macro my_macro(foo = 'bar') %}
<p>{{ foo }}&...
1
vote
Get section handle of an entry inside of an EntryField
You haven't executed your element query: https://craftcms.com/docs/4.x/element-queries.html#executing-element-queries
(If you attempted to do this in Craft 3 it would have given you a slapped wrist by ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
templating × 1658entries × 130
craft3 × 123
plugin-development × 94
matrix × 83
categories × 64
assets × 62
forloop × 47
variable × 47
field × 46
filter × 40
datetime × 39
plugin-craftcommerce × 36
array × 35
entry × 34
url × 34
conditional × 34
cache × 32
navigation × 30
users × 29
routes × 29
plugins × 27
sections × 27
image × 23
javascript × 23