Skip to content

Commit fd2dff9

Browse files
authored
Merge pull request #896 from kenjis/docs-customization/views
docs: add "Customizing Views"
2 parents 224a3bb + 874e024 commit fd2dff9

2 files changed

Lines changed: 40 additions & 0 deletions

File tree

docs/customization/views.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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.

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ nav:
106106
- quick_start_guide/using_authorization.md
107107
- Customization:
108108
- customization/table_names.md
109+
- customization/views.md
109110
- customization/route_config.md
110111
- customization/redirect_urls.md
111112
- customization/validation_rules.md

0 commit comments

Comments
 (0)