Hi,
I’m trying to build a webpage that will, for each project, generate a link with a different svg icon that are not linked to the project, but for now, hardcoded.
So, if I have 2 projects, it will have a svg for the first project, and another svg for the other project. (the svgs won’t be stored in the image project, they are not related to the project)
I made a for that count how many project I have on the page and then create an img
tag with a if condition. Something like : If it’s the first project then apply that svg, if it’s the second, this other svg, and so on.
<?php for ($i = 1; $i <= $contenu->projets()->toPages()->count(); $i++): ?>
<?php if ($i == 1): ?>
<img src="https://picsum.photos/100/100" alt="">
<?php endif ?>
<?php if ($i == 2): ?>
<img src="https://picsum.photos/100/200" alt="">
<?php endif ?>
<?php if ($i == 3): ?>
<img src="https://picsum.photos/100/300" alt="">
<?php endif ?>
<?php endfor ?>
Actually, this is working quite nicely, but, it’s not very dynamic, nor the good way to go I feel.
Maybe there is a better way?
Later, on my webpage panel, I could have a collection with all my svgs, svg1, svg2, etc… that I could iterate through.
Thanks.