Post by emon.msc » Mon Nov 28, 2022 8:36 pm

Hi, Hope you all are doing well .
I want to show attributes of a product that will show max 5 attributes value. I am following this way for showing attributes & working fine but how do i show max 5 in this list ? is there any way to set the length / limit of the list ?
here is the code :

Code: Select all

<div class="spec-list">
{% for attribute in attribute_group.attribute %}
   <ul>
     <li>{{ attribute.text }}</li>
  </ul>
 {% endfor %}
 <div>
somehow i having it with custom css like this way .

Code: Select all

 .spec-list li:nth-child(n + 6) {
    display:none!important;
}
but i want to have it on a dynamic way. can you think the way ?

Thank you All Friends !
Last edited by emon.msc on Tue Nov 29, 2022 1:24 pm, edited 1 time in total.

Newbie

Posts

Joined
Tue Oct 05, 2021 3:49 pm

Post by straightlight » Tue Nov 29, 2022 5:20 am

OC version.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by emon.msc » Tue Nov 29, 2022 12:38 pm

OC VERSION 3.0.3.8

Newbie

Posts

Joined
Tue Oct 05, 2021 3:49 pm

Post by DigitCart » Tue Nov 29, 2022 2:32 pm

Hi
You better limit this in the controller level, But if you want to do this in twig file, You need to use loop.index:
https://twig.symfony.com/doc/2.x/tags/for.html

My Extensions


User avatar
Active Member

Posts

Joined
Thu Jun 22, 2017 5:32 pm

Who is online

Users browsing this forum: nancyagarwaal, Semrush [Bot] and 95 guests