batric
(Batricbatric)
May 31, 2012, 6:06pm
1
Hello everyone,
Can you please explain me the reason why is there a "views" subfolder in the themes?
Can I override it?
I would prefer if I can cut down that one folder level in the theme, so my layout file would be directly in:
/themes/default/main.php
I know that I can override settings for each view separately, but writing the path to the view feels kinda like a hack.
Thank you for your help!
rootbear
(Alex Xm)
May 31, 2012, 6:56pm
2
my understanding:
the /themes/<theme-name>/views IS actual the override of the folder /protected/views,
to use it simply add in /protected/config/main.php:
'theme'=>'<theme-name',
then you do whatever changes in /themes/<theme-name>/views whenever you would do it in /protected/views without specifying the theme.
and i don’t see anywhere you need to hard code theme view folder, yii takes care of it for you. as always
batric
(Batricbatric)
June 2, 2012, 4:19pm
3
Thanks for the reply, but it’s not clear still.
Why there is one more folder level in the theme folder? How can I remove it?
This is how YII does it by default:
/themes/default/views/main.php
I want to have it this way:
/themes/default/main.php
Thanks!
rootbear
(Alex Xm)
June 4, 2012, 4:22am
4
ok, assume your theme’s name is theme-name and do this:
drop a file test.php in 1) /themes/ 2) /themes/theme-name/ 3) /themes/theme-name/views/
<?php echo 'hello world';?>
and try to access via
1) http://webroot/themes/test.php
2) http://webroot/themes/theme-name/test.php
3) http://webroot/themes/theme-name/views/test.php
you are not supposed to see 3), reason: it should be protected not public. at the sametime you can have your public folders under /themes/theme-name/ like
themes/theme-name/js <-- public
themes/theme-name/css <-- public
themes/theme-name/images <-- public
themes/theme-name/views <-- protected by .htaccess
.htaccess
deny from all