Hello,
I want to set a php condition with the value of a field.
I have a text field (named "level") with numerical values (1 to 9).
I want to set a php condition in my category template to display all items with "level" = 1, then below display all items with "level" = 2, etc.
I know I can display all my items by ordering the listing with the value of "level" field in FC parameters, but I want to add some text between all "level" before displayins items.
So I have to modify my category_items.php of my template and set manually the condition.
In category_items.php, I have this for now :
Code:
<?php foreach ($items as $i => $item) : ?>
___ some html ___
<?php endforeach; ?>
And of course it display all items regardless the "level" field value.
If I order by field value, I obtain this :
- item with "level" set to 1
- item with "level" set to 1
- item with "level" set to 1
- item with "level" set to 1
...
- item with "level" set to 2
- item with "level" set to 2
...
- item with "level" set to 3
- item with "level" set to 3
- item with "level" set to 3
- item with "level" set to 3[/code]
And what I want :
Code:
<h3>Level 1</h3>
- item with "level" set to 1
- item with "level" set to 1
- item with "level" set to 1
- item with "level" set to 1
<h3>Level 2</h3>
- item with "level" set to 2
- item with "level" set to 2
<h3>Level 3</h3>
- item with "level" set to 3
- item with "level" set to 3
- item with "level" set to 3
- item with "level" set to 3
Etc.
What is the correct FC syntax please ?
Thank for your answer.
Regards.