If you have been developing on Ibexa for a few years, you have probably got into the habit of using the Symfony controller ibexa_content::viewAction to pass custom parameters to a view.
Those days are over. With parameter support arriving in the native Twig functions, the tide is turning. Here is why you should change your habits today.
We used a Symfony sub-request to inject our data:
{# ❌ Now to be avoided for simple renders #}
{{ render(controller('ibexa_content::viewAction', {
'contentId': content.id,
'viewType': 'line',
'params': { 'my_param': 'custom_data' }
})) }}
We use the dedicated helper, which handles everything internally:
{# ✅ The current recommendation #}
{{ ibexa_render(content, {
'viewType': 'line',
'params': { 'my_param': 'custom_data' }
}) }}
Symfony's render(controller(...)) function creates what is known as a sub-request. The Symfony kernel has to recreate a complete lifecycle (Request, Kernel Events, etc.). By contrast, ibexa_render with the default method (direct) calls the rendering engine directly. It is lighter, faster and uses less memory.
By using ibexa_render, you clearly state that you are rendering a CMS object. The code is shorter and much easier to maintain for a developer new to the project.
The params block of the Twig function does exactly the same thing as the controller's. You lose no functionality, but you gain clarity.
The switch is painless. In your target template (your "View Template"), nothing changes. The variables you pass in the params array remain accessible under the same name.
Migration example:
Since our last article, Ibexa Dataflow has gone from version 6.1.2 to 7.0.0: a richer ...
New dashboard, new design, new analyses and an ambitious roadmap: Security Audit moves to version ...
While AI assistants have revolutionised code production by significantly speeding up development, their widespread use ...
Fed up with having your job logs in the database? Even more fed up with ...
If you have been developing on Ibexa for a few years, you have probably got ...
Code Rhapsodie is taking over maintenance of Patrick Bussmann's oauth2-apple package. This fork ensures the ...
Taxonomy keyword suggestion is available in Ibexa DXP with the LTS update pack and the ...
Importing a very large SQL file can be problematic, sometimes causing your virtual machine (VM) ...
Sylius and Shopware are two tools (frameworks) for building an e-commerce site. How do you ...