|
| 1 | +# Customizing Views |
| 2 | + |
| 3 | +Shield provides the default view files, but they are sample files. |
| 4 | +Customization is recommended. |
| 5 | + |
| 6 | +If your application uses a different method to convert view files to HTML than |
| 7 | +CodeIgniter's built-in `view()` helper, see |
| 8 | +[Integrating Custom View Libraries](./integrating_custom_view_libs.md). |
| 9 | + |
| 10 | +## Change $views |
| 11 | + |
| 12 | +Change values in `$views` in the **app/Config/Auth.php** file. |
| 13 | + |
| 14 | +For example, if you customize the login page, change the value for `'login'`: |
| 15 | + |
| 16 | +```php |
| 17 | +public array $views = [ |
| 18 | + 'login' => '\App\Views\Shield\login', // changed this line. |
| 19 | + 'register' => '\CodeIgniter\Shield\Views\register', |
| 20 | + 'layout' => '\CodeIgniter\Shield\Views\layout', |
| 21 | + 'action_email_2fa' => '\CodeIgniter\Shield\Views\email_2fa_show', |
| 22 | + 'action_email_2fa_verify' => '\CodeIgniter\Shield\Views\email_2fa_verify', |
| 23 | + 'action_email_2fa_email' => '\CodeIgniter\Shield\Views\Email\email_2fa_email', |
| 24 | + 'action_email_activate_show' => '\CodeIgniter\Shield\Views\email_activate_show', |
| 25 | + 'action_email_activate_email' => '\CodeIgniter\Shield\Views\Email\email_activate_email', |
| 26 | + 'magic-link-login' => '\CodeIgniter\Shield\Views\magic_link_form', |
| 27 | + 'magic-link-message' => '\CodeIgniter\Shield\Views\magic_link_message', |
| 28 | + 'magic-link-email' => '\CodeIgniter\Shield\Views\Email\magic_link_email', |
| 29 | +]; |
| 30 | +``` |
| 31 | + |
| 32 | +## Copy View File |
| 33 | + |
| 34 | +Copy the file you want to customize in **vendor/codeigniter4/shield/src/Views/** |
| 35 | +to the **app/Views/Shield/** folder. |
| 36 | + |
| 37 | +## Customize Content |
| 38 | + |
| 39 | +Customize the content of the view file in **app/Views/Shield/** as you like. |
0 commit comments