Yii App in iframe

Hi,

I’m creating a Facebook application using Yii, and wondering how to have links within the app redirect the application host page as though it were the application?

E.g. When clicking a link in the app:

Instead of the iframe going to:

applicationDomain.com/controller/action

Have the browser go to:

apps.facebook.com/{appNamespace}/controller/action

I can get the browser to follow the link by using [target=’_top’] in the links, but that just sends the browser to the Yii application domain (away from the Facebook application), instead of appending the relative path to the url.

Any ideas?

hmm, would be nice to know how to do it. Have you found any solution to it?

I got it working by adding ‘baseUrl’ to the urlManager component declaration in config/main.php:


'urlManager'=>array(

    'baseUrl'=>'http:/apps.facebook.com/{appNamespace}',

    'urlFormat'=>'path', //optional

    'showScriptName' => false, //optional

    'rules'=>array(

	//.....your rules

    ),

),

You’ll still need to add ‘target="_top"’ to your links:


CHtml::link('text',array('controller/action'), array('target'=>'_top'));

just found this. I think it could be useful in your case as well. So you wouldn’t need to change the baseUrl in the config file.


Yii::app()->request->baseUrl;