0
I have a query, which I imagine is in object-oriented php, which in my case I’m at the beginning of studies(I know I’m late).
I have a platform Xtech, and at the time of display of some features, I have the following code
{% if product.properties|count > 0 %}
<div class="clearfix">
{% for prop in product.properties %}
{% if properties_flatten[prop.id].image is not empty %}
<img src="{{ host_url("uploads/images/small/" ~ properties_flatten[prop.id].image) }}">
{% else %}
<h5>{{ properties_flatten[prop.id].excerpt }} {{ properties_flatten[prop.id].name }}</h5>
{% endif %}
{% endfor %}
</div>
{% endif %}
This code displays the product features, Color: White, Black, Blue, Red.
I would like to alphabetize the result.
Blue, White, Black.
But I don’t know how to do that in this kind of object orientation.
Please if anyone knows and can help.
I’m sorry if I’m talking nonsense.
Thank you
Hello. I don’t have enough reputation to comment. Why not sort the query directly in your database? So you wouldn’t have the trouble of selecting the information, then sort it in your code. Let the database manage it for you.
– Marcelo Ágil
I don’t know this syntax, so I really have no idea of the tech used there, but in many frameworks, the object comes with methods to help with that, an example would be in the foreach that you run the prop, call something in the style
prop.orderBy('desc')
. If you know what this technology is, it will help. Suddenly a link to documentation.– David Dias
Alias,
product.properties.groupBy('desc')
– David Dias
@Daviddias - thank you, I will analyze. I thank you for the prompt reply.
– Marcelo Rossi