generate standalone non HTML view file

Hi all,

for a graphic library I need a dedicated config file. It is not HTML or JavaScript, it is simply an text file with the extension .cfg

From a developer perspective it is similar to a view, it is used to configure visible elements and therefore could be perfectly generated by an *.php file from within Yii.

But for this I have a lot of questions:

Is it in general possible to generate non HTML files?

How to generate stand alone view files, without all this main.php, layer.php etc stuff?

How to place this generated file for example in the /js directory to be loadable from the views?

Any help would be appreciated


You don’t need a view for every action in your controller…

And you don’t need to put that function in your controller either.

Put it in your model. I think it belongs there.

And use regular PHP file IO.

Hi jacmoe,

I have the gut-feeling it don’t belong to the model.

I’m talking about a configuration file, similiar to a .css to configure color, size and text for a graphic. I have the basic data in the model, but this only helps displaying these data in a nice way and would pollute the model with a lot of visualization depended data. Furthermore I need different ways to show the same data - a typical use case for view-controller files.

So I’m quite sure generating this config file have to be places in a view. Nevertheless, I need a view to create the html-page which contains the graphic.

But still the question, how and where shall I generate this stand-alone config file?



A config file is data.

If you want to generate views from that data, let your controller generate a view from it and present it to the view.

I have a similar situation and ended up using renderPartial instead of render to achieve what I wanted. By setting the last two parameters ($return and $processOutput) to be (true and false) the view is processed just like a normal view but isolated from the standard HTML output.

In a site I have the option for generating an ODT document file from some of the data. Initially I wrote a new method in the controller to do this and it was working fine. However, the method was fairly long and since it was only concerned with producing output I felt it would be better to move it to a view. This way I could conceptually stick to the MVC architecture and keep my controller lean. Functionally it makes little difference but I just had a better feeling about keeping it among the views even though this particular view has nothing to do with HTML.

P.S.: BTW I’m using php-odt to generate the ODT.