Answer the question
In order to leave comments, you need to log in
Saving XML from a Yii template?
Good afternoon. It was required to give the user an XML file.
I work in yii. For convenience, I made myself several basic templates and fill them with information.
I decided to generate it using $this->render('export_xml', array('data'=>$data));
In this regard, questions arise. render loads the main layout by default, I want to avoid this.
I solved this issue by making myself an empty layout and $this->layout = '//layouts/blank'; But it seems to me that there is a more logical and correct solution, but I can’t find it yet.
And the second, most important question. Is it possible to force the template to be given as a file?
Answer the question
In order to leave comments, you need to log in
To prevent the layout from loading, use renderPartial():
$this->renderPartial('export_xml', array('data'=>$data));
Is it possible to force the template to be given as a file?
And what about the template?
Unless
$this->layout = false; - In the controller.
And then put any headers, for example, those from the xml file and output whatever you want.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question