vova07 / yii2-start

Yii2-Start application
Other
273 stars 115 forks source link

Override views. #94

Closed nunomaduro closed 9 years ago

nunomaduro commented 9 years ago

Hey,

What is the best option to override views ?

Example: Override header, override mail change, etc.

vova07 commented 9 years ago

Hello, The best practice in my opinion is to use multiple paths. This is clean and easy way to solve all possible situations.

From docs:

'pathMap' => [
    '@app/views' => [
        '@app/themes/christmas',
        '@app/themes/basic',
    ],
]

In this case, the view will be searched in @app/themes/christmas/site/index.php then if it's not found it will check @app/themes/basic/site/index.php. If there's no view there as well application view will be used.

UPD:

A real example for admin theme

'components' => [
...
'view' => [
    'theme' => [
        'class' => 'vova07\themes\admin\Theme',
            'pathMap' => [
                '@backend/views' => [
                    '@backend/themes/myThemeName/views',
                    '@vova07/themes/admin/views',
                ],
                '@backend/modules' => [
                    '@backend/themes/myThemeName/modules',
                    '@vova07/themes/admin/modules'
                ]
            ]
        ]
    ]
...
]
caceresvega commented 9 years ago

Hello, I would like to know where to place the controller, model and view generated with crud in yii2-start. Because I have placed in the backend and I mouestra Page Not Found message. Thank you

vova07 commented 9 years ago

Hi @caceresvega , You my put them to the default folders. Of course there are missed by default, but you can create them by your self. So models will be placed in backend/models and controllers in backend/controllers directory. All like in advanced template. Yes, and don't forgot to add the URL rule for your new controllers, something like: '<_c>/<_a>' => '<_c>/<_a>' Good luck!

caceresvega commented 9 years ago

Thank worked properly

caceresvega commented 9 years ago

Dear I have tried to set yii2-start a hosting 1and1.com and I have not achieved it shows me the error of Internal Server Error and all paracer be a problem with the configuration of the .htaccess file (for locally works) thatYou have the following code:

Mod_Autoindex

# Disable Indexes Options -Indexes

Mod_Rewrite

Options -Multiviews RewriteBase / ``` # Enable symlinks Options +FollowSymlinks # Enable mod_rewrite RewriteEngine On # Backend redirect RewriteCond %{REQUEST_URI} ^/backend RewriteRule ^backend/(.*)$ /backend/web/$1 [L] # Statics redirect RewriteCond %{REQUEST_URI} ^/statics RewriteRule ^statics/(.*)$ /statics/web/$1 [L] # Frontend redirect RewriteCond %{REQUEST_URI} ^(.*)$ RewriteRule ^(.*)$ /backend/web/$1 [L] ```

I would appreciate if you have any ideas to help me asolucionar this problem, have the url where the site is hosting de1and1.com http://qs.redbridgeinsurance.com

My email is: caceresvega@gmail.com Thank you very much for the help you can give me Juan Alberto Caceres Vega

vova07 commented 9 years ago

Hi @caceresvega , What is the exact internal error that you got? Check the log file please on the server side, and provide some info about what's going wrong, because without any info I really can't help with anything.

vova07 commented 9 years ago

Yes, and if it's possible, please create a new issue for this conversation. It's not related with the current issue. I'll help you there.