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 ...
user avatar
  • 6,341
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 = ...
user avatar
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 }}&...
user avatar
  • 6,830
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 ...
user avatar
  • 3,959

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