public function actionCreate($id = '') { if ($id == '') { $model = new SubPage(); } else { $model = SubPage::model()->findByPk($id); } $this->layout = 'layout_user'; // uncomment the following code to enable ajax-based validation if (isset($_POST['ajax']) && $_POST['ajax'] === 'sub-page-create-form') { echo CActiveForm::validate($model); Yii::app()->end(); } if (isset($_POST['SubPage'])) { $model->attributes = $_POST['SubPage']; if ($model->validate()) { $model->save(); // form inputs are valid, do something here //return; Yii::app()->user->setFlash('success', "Your sub-page has been created successfully."); $this->redirect(Yii::app()->baseUrl . '/index.php/user/dashboard'); } } $this->render('create', array('model' => $model)); }
function SabPages($val) { $page = SubPage::model()->findAll('bussiness_page_id=:pageId', array(':pageId' => $val)); $val = ''; if (!empty($page)) { $val = '<ul>'; foreach ($page as $p) { $val .= "<li>" . $p['name'] . "</li>"; } $val .= '</ul>'; } return $val; }
<?php $model = SubPage::model()->with('page')->findByPk($id); ?> <div class="well" style=" float:left;margin-left:20px; margin-top: 0px; width: 250px; height: auto;"> <a href="#" class="thumbnail" rel="tooltip" data-title="<?php echo $model['page']['company_name']; ?> " data-original-title=""> <img src="<?php echo Yii::app()->baseUrl; ?> /uploads/business_page_<?php echo $model['page']['user_id'] . '/' . $model['page']['image']; ?> " alt=""> </a> <table class="table"> <tbody><tr> <td> </td> </tr> <tr> <td>Subpage Name</td><td><?php echo $model['name']; ?> </td> </tr> <tr> <td>Domain</td><td><?php