T
T
Timur2013-06-20 22:31:12
Yii
Timur, 2013-06-20 22:31:12

Yii and smarty-renderer

I am developing a SaaS application in Yii divided into frontend and backend and a few more parts. The task is to use Smarty on the frontend, but the difficulty is this:

The frontend's task is to “give out” different themes depending on the HTTP HOST. Each such site is a separate folder, which is located in webroot.themes.http_host

On the frontend there is actually only one controller, in which there is only one action that renders different views depending on the HTTP HOST and GET parameters

I need using smarty- renderer to render these same views, but the structure needs to be like this:
The webroot.themes.http_host folder should contain the "index.tpl" file and the "pages" folder, in which it can find an unlimited number of files.

The problem is that with such a structure, I have to write the full path for view files in the form of aliases, including in *.tpl files when using {include file="..."}

Question: how to set the default path and where do exactly that?
Now in the controller action I have to write the view path:

$this->render('webroot.themes.'.Y::param('domain').'.index', array('page' => $page));

This is not critical when used in actions, but when using {include file="..."} it is a problem.

I tried to change the values ​​just before calling $this->render(): Yii::app()->viewPath and Yii::app()->viewRenderer->getSmarty()->setTemplateDir()
But this throws an Exception about unable to find view file.
Please help! Especially, I would like to get an answer from samdark

PS It is impossible to prescribe path aliases in smart, in {include file="..."} because the application is Saas, and this will be done by end users.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
Timur, 2013-06-21
@XAKEPEHOK

He asked, he answered.

Yii::app()->viewRenderer->getSmarty()->setTemplateDir(Y::alias('webroot.themes.'.Y::param('domain')));
$this->render('webroot.themes.'.Y::param('domain').'.index', array('page' => $page));

C
Crank, 2013-06-21
@Crank

I wonder what tasks it is advisable to use such a bunch for solving?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question