开发者

views or controller? symfony mvc

<?php forea开发者_JAVA技巧ch ($jobeet_job_list as $jobeet_job): ?>
<tr>
  <td><a href="<?php echo url_for('job/show?id='.$jobeet_job->getId()) ?>"><?php echo $jobeet_job->getId() ?></a></td>

  <td><?php echo $jobeet_job->getCompany() ?></td>

  <td><?php echo $jobeet_job->getIsPublic() ?></td>
  <td><?php echo $jobeet_job->getIsActivated() ?></td>

</tr>
<?php endforeach; ?>

for example would like add class to TR in depending IsPublic();

<?php foreach ($jobeet_job_list as $jobeet_job): ?>
<tr class=" <?php if ($jobeet_job->getIsPublic() == 0) { echo "public"; } else {echo "unpublic";})?> ">
 <td> <?php if ($jobeet_job->getIsPublic() == 0) { echo "public"; } else {echo "unpublic";})?> </td>
    </tr>
    <?php endforeach; ?>

gives:

<tr class="public"> or <tr class="unpublic"> and
 <td> public </td> or <td> unpublic </td>

the instruction IF ELSE can be in VIEW? should be in the controller in correct MVC?


This should be in view, as view decides which markup needs to be returned. Controller is only to provide data necessary to make the decision (and the data that is going to be shown of course, but not name of CSS class in this one).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜