Home » PHP » Twig » Top Twig Template Interview And Answer Part 4

Top Twig Template Interview And Answer Part 4

1. How we can append text in title with separator in twig template?

{% do pimcore_head_title().append('Pimcore Website') %}
{% do pimcore_head_title().setSeparator(' : ') %}

2. How can we include image through asset in twig template?

<img src="{{ asset('static/img/logo-white.svg') }}" alt="Image">

3. How can we check asset is the instance of Asset class and get image in twig template?

{# @var asset \Pimcore\Model\Asset #}
{% if asset is instanceof('\\Pimcore\\Model\\Asset\\Image') %}
{{ asset.getThumbnail(image).getHTML({ class: 'my-class' })|raw }}
{% else %}

4. How can we include the file and pass the params in twig template?

{% include 'file.html.twig' with { doc: doc } only %}
{% include 'file.html.twig' with { doc: doc } %}

5. How can we check the existence of value in the group in twig template?

{% if child.getType() in ['page', 'link'] %}
{% endif %}

Check Also

Top Twig Template Interview And Answer Part 5

1.How can we loop the array in twig template? {% for item in test %} …

Leave a Reply

Your email address will not be published. Required fields are marked *