Post by awaix » Fri Sep 01, 2017 2:36 am

Im customising the product page as i need to display one particular attribute right after the title and i have managed to do that but the content of that attribute has html in it and when i use twig it encodes the html instead of rendering it.

here is the code i am using to display the attribute:

Code: Select all

            {% if attribute_groups %}
              {% for attribute_group in attribute_groups %}
                {% if attribute_group.name == 'technicaldetails' %}
                  {% for attribute in attribute_group.attribute %}
                    {{ attribute.text }}
                  {% endfor %}
                {% endif %}
              {% endfor %}
            {% endif %}
previously i was using opencart 2 where php was used instead of twig and this is the code which worked for me then:

Code: Select all

<?php if ($attribute_groups) { ?>
    <?php foreach ($attribute_groups as $attribute_group) { ?>
      <?php if ($attribute_group['name'] == 'technicaldetails') { ?>
        <?php foreach ($attribute_group['attribute'] as $attribute) { ?>
          <?php echo html_entity_decode($attribute['text']); ?><br />
        <?php } ?>
      <?php } ?>
    <?php } ?>
  <?php } ?>
how can i display the html in twig? I've already tried using: "{{ attribute.text }}", "{{ attribute.text | raw }}" and "{{ attribute.text | e }}".
here is the html im trying to render :

Code: Select all

<ul class="technicaldetails">
<li>some text</li>
</ul>
please help on these.
Thanks.

New member

Posts

Joined
Sat Apr 13, 2013 8:22 pm

Post by cyclops12 » Fri Sep 01, 2017 3:02 am

not sure but maybe This will help

Expert Member
Online

Posts

Joined
Sun Sep 27, 2015 1:10 am

Post by boicute.14 » Tue Sep 19, 2017 8:15 pm

We can use html_entity_decode in backen or use javascript for html entities decode

Opencart Developer|Thiết kế website|Thiết kế website tại Đồng Nai


Newbie

Posts

Joined
Sat Oct 22, 2016 2:08 pm
Who is online

Users browsing this forum: No registered users and 45 guests