I have a site that I am thinking about updating to Yii that has a section ‘About’ that has around six subheadings. some are static information and some have to attach to a database. static pages go in the ../pages directory, if I understand the framework correctly.
How would I modify site/about from the default webapp to change show the dynamic pages.
example:
About
|- Contact Information => is static telephone numbers / mailing address / etc…
|- Press Releases => information is pulled from a database.
I think you can do something like $model=Content::model()->findByPk($id); from a controller and then in rendered view you can put some static information (Contact information) followed by $model in Press release.
Of course you need a model to store data information.
You can do a page full static, or full db driven or both, my suggestion doesn’t change
In any case, for static content, you can put it directly inside the view. So in views/page/contact you can put:
<h1>this is my static content</h1>
<p>Simply put your static content in the view</p>
in the controller you render view without passing argument. Instead you have to pass argument when view needs content taken from a recordset. Example:
$this-render('sponsors',array('model'=>$model));
where $model contains db data. Then you can render $model in the view.
Of course you can mix static and dynamic data in your view:
<h1>this is my static content</h1>
<p>Simply put your static content in the view</p>
<?php print_r($model); // it takes data from $model, so from DB ?>
<p>And of course I can write other static contents here!</p>