So I’ve got a model, and in the view where I output the data, I want to check if there is anything coming from the model.
Is this a reasonable way to check for data? It seems like the return from model() is just a simple object… I suppose I could try is_array() or is_object() to tell if data is being returned?
Model:
<div class="theme-gallery">
<? if (count($model)) { ?>
<ul>
<? foreach ($model as $theme) { ?>
<li><div><?php echo $theme->themeName;?></div></li>
<? } ?>
</ul>
<? } else { ?>
Currently no themes. Add One.
<? } ?>
</div>
Controller:
public function actionMyThemes()
{
$model = Theme::model()->user()->findAll();
$this->render('my-themes', array('model'=>$model));
}