Get Name of rendered File

Hi,

I currently try to draft a nested layout. My idea is to have a section that contains the desktop layout and one that contains the mobile layout. However, to do so I have to render different files into the layout. I currently itend to do so by rendering one file in my controller but have the others be dynamically derived from that file. I.e. if I render a file named ‘view’ I’ll dynamically also render the file ‘view_Mobile’ in the mobile section of the template.

My main problem is that I can not access the rendered file in the template (so, to stick with the example, get a string such as ‘view.php’). Is there any way to do so?

Thanks!

So within the layout, you want to know which view file was rendered into the $content? I don’t know of any way to achieve that.

That being said, your approach for a mobile-friendly website sounds a bit awkward. Check out http://getbootstrap.com/

Thanks for your reply. Actually, I’m using bootstrap, but there are several sides which are better off with separate designs. Anyway, I decided to discard my approach since there are only very few sides which require to do so.

Sorry for my english.

we can pass the variable from view to layout as params.

In view file




$this->params['page']='index';



in layout we will get this value by




if(isset($this->params['file'])){

    echo $this->params['file'];

}