我无法想到一个可行的解决方案,可以在餐厅的菜单页面为每个课程创建PHP模板的交替部分。我想创建一个可以实现这个结果的模板:
<section class="well well__off1>
<div>Starters</div>
.... menu list ...
</section>
<section class="bg-secondary well well__off1>
<div>Mains</div>
.... menu list ...
</section>
<section class="well well__off1>
<div>Steaks</div>
.... menu list ...
</section>
etc
etc
我正在运行的当前模板是这样的。如何为每个课程替换CSS部分?
<section class="well well__off1">
<div class="grid_8">
<?php foreach ($MDayMeals as $courses => $meals): ?>
<h4><?php echo $courses; ?></h4>
<?php foreach ($meals as $meal): ?>
<div class="name-wrap">
<?php echo htmlencode($meal['name_of_dish']) ?>
</div>
<?php endforeach ?>
<?php endforeach ?>
</div>
</div>
</section>
有关如何实现这一目标的任何想法?
由于 特里
答案 0 :(得分:2)
var user = UserManager.FindById(User.Identity.GetUserId());
答案 1 :(得分:1)
希望这有帮助:
<?php foreach ($MDayMeals as $courses => $meals): ?>
<?php if($i%2===0): //check value odd or even
?>
<section class="well well__off1">
<?php else:?>
<section class="bg-secondary well well__off1">
<?php endif;?>
<div class="grid_8">
<h4><?php echo $courses; ?></h4>
<?php foreach ($meals as $meal): ?>
<div class="name-wrap">
<?php echo htmlencode($meal['name_of_dish']) ?>
</div>
<?php endforeach ?>
</div>
</section>
<?php $i++; ?>
<?php endforeach ?>