Quantcast
Channel: Yii Framework Forum
Viewing all articles
Browse latest Browse all 18717

Beautiful Urls With Slug

$
0
0
Hi guys,

I created a controller pageController to handle pages, and I make it the default controller in the config/main.php file.

In this controller I make the default action as 'show' which looks like that:
public function actionShow( $slug = '' ) {

		if ( empty( $slug ) ) {
			$model=Pages::model()->findByAttributes( array( 'slug' => 'accueil' ) );
		}
		else {
			$model = Pages::model()->find('slug = :slug', array(':slug' => $slug));

			if($model===null) {
				//throw new CHttpException(404,'The requested page does not exist.');
				$slug = 'not found';
			}
		}


		$this->render('page', array(
			'model' => $model,
			'slug' => $slug,
		));
	}



The problem is that I can't figure out how to pass the slug from the request to this actionShow() method.

Thanks in advance :)

Viewing all articles
Browse latest Browse all 18717

Trending Articles