-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* New User / Field twig functions * Implement review comments --------- Co-authored-by: Adrien Dupuis <[email protected]>
- Loading branch information
1 parent
cb59d52
commit d2a2bb8
Showing
4 changed files
with
72 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
docs/templating/twig_function_reference/user_twig_functions.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
--- | ||
description: User Twig functions enable getting repository user information. | ||
page_type: reference | ||
--- | ||
|
||
# User Twig functions | ||
|
||
### `ibexa_user_get_current()` | ||
|
||
`ibexa_user_get_current()` returns the User object (`Ibexa\Contracts\Core\Repository\Values\User\User`) of the current user. | ||
|
||
``` html+twig | ||
{{ ibexa_user_get_current().login }} | ||
``` | ||
|
||
You can get the underlying Content item, for example to display the user's last name, | ||
by accessing the `content` property: | ||
|
||
``` html+twig | ||
{{ ibexa_render_field(ibexa_user_get_current().content, 'last_name') }} | ||
``` | ||
|
||
### `ibexa_current_user()` | ||
|
||
`ibexa_current_user()` is a deprecated alias of `ibexa_user_get_current()`. | ||
|
||
|
||
### `ibexa_is_current_user()` | ||
|
||
The `ibexa_is_current_user()` Twig function checks whether a user is the current repository user. | ||
|
||
#### Examples | ||
|
||
```html+twig | ||
{% if ibexa_is_current_user(version_info.author) %} | ||
<!-- Display edit link --> | ||
{% endif %} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters