Determine whether a render or partialRender should take place (AJAX)

Hi All,

I’m seeking peoples thoughts on the best way to implement AJAX functionality to render links in a specific DIV, but if you go to that link specifically then it creates the entire wrapper.

What I mean by that is… I have my layout which has my standard header and footer in it… A user enters through index.php and the page displayed properly.

However what I would like to do is that if a user clicks on a link within my site (page.php for example), that page.php is loaded via ajax into the content div. This part I can do fairly easily.

The problem I have encountered is that if I then go and access page.php directly then it only shows the partialRender content and doesn’t have the layout wrapped around it, so what I need to do is determine if the content has a layout wrapped around it or not.

Does anyone know how I could achieve this in Yii?

You can check if the request is an ajax request or not by checking Yii::app()->isAjaxRequest