Rendering Several Dynamic Pages Using Single View File

How can I render several dynamic pages with single view file. I have LpController whose Index Action will bring records from db based on querystring parameter. For example, if I have links www.mysite.com/index.php/lp/palm_jumeirah, www.mysite.com/index.php/lp/downtown_dubai the records I need to fetch will be for these two districts without the underscore: palm jumeirah and downtown dubai.

So do I need to do all the coding in the Index action of controller ? How would I get the district palm_jumeirah for use in query ? use Yii::app()->getQueryString() ? and what do in ‘urlManager’ rules array ?

‘<controller:\w+>/<action:\w+>’=>’<controller>/index’, ??

shaani sab bohat easy task hai pehli baat tu ye hai ap ko apni url design krni hai. main aik simple approach follow kron ga, ap apne controller main kuch is tarah add kr len


function actionIndex(){

  $id = end(explode("_", $_GET['page']));

  $this->render("youViewName", array(

     "page" => Page::model()->findByPk($id),

  }

}

aur phir apne view main aap page variable ka istamal kr sakte hain


$page->title;

$page->contents;

aur jab app apne pages ko link kro tu make sure k app apne table id bhi add kr end per kuch is trah


<?php $url = preg_replace(" ", "_", strtolower($page->title)); ?> // app aik helper add kr sakte hain url banaay k liye

<?php echo CHtml::link("First Page", Yii::app()->createUrl($url."_".$page->id)); ?>

aur ap ki urlManager ko kuch is tarah kr loo

and there you have it