Different background on li items

Hello,

I’m trying to get a list of div boxes. Depending on a category the boxes should have either a black or red background.

This is part of my blueprint

cat:
    label: Category
    type: radio
    options:
      1: Hotel
      2: Transport

This is each li-item

<?php $count = 0; foreach($projects as $project): ?>

  <li>

	<?php
		$style = 'background:';
		$given = $project->cat() = 1 ? 'red;' : 'black;';
		$style .= $given;
	?>

		<div class="project-info" style='<?php echo $style; ?>'>Some text</div>

  </li>

<?php $count++; endforeach; ?>
	
</ul>

They all end up the same, either black cat < 1 or red cat < 2. If I use cat = 1 as above everything breaks. Can anyone tell me what I’m doing wrong?

`You have to use a comparison operator instead of an assignment operator; and “1” is a string in this context, not an integer, so:

$given = $project->cat() == "1" ? 'red;' : 'black;';

Thanks a lot texnixe :grinning: