How To Render() A $Variable?

Hi there, my question is pretty straight forward.

[color="#0000FF"]How can I render a full-page (View + Layout) but without using a file?[/color]

I’m constructing a CMS in a SaaS for multiple tenants, so obviously I can’t use a file for each page and domain, but as far as I can understand…


$this->render('index');

This renders the [view file] "index.php" + [layout file]"main.php".

so I would like to do something like that:


$this->render($output);

Anyone have a clever approach? O0

"cache" maybe?

Hi!

try this


$this->renderText($your_output)

check this for more details

http://www.yiiframework.com/doc/api/1.1/CController#renderText-detail

if the output contains both content and layout just use echo


echo $your_output;

Yii::app()->end();

Thank you for your reply,

but the idea is to have a full render(view + layout) and echo or cache the output.

or maybe what I’m asking is not that…

how could I trigger an action without a function in the controller?

ex:




public function actionIndex()

{

	$this->render('index');

}



to something dynamic like:





	public function actionDynamic( $output)

	{

		$this->render( $output );

	}



I hope you see what I’m trying to get at :D

Since the dynamic action haven’t different logic by another dynamic action, it should be only one!

you could make actionTheOne($id)

and according to $id you render the appropriate view

also there is a similar way to do that without creates an action, and I am sure that you have already used it.

http://www.yiiframework.com/wiki/22/how-to-display-static-pages-in-yii/