-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
EZP-29998 As a developer, I want to define icons for Content Types #520
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -503,6 +503,70 @@ class OrderedTabSubscriber implements EventSubscriberInterface | |||||
} | ||||||
``` | ||||||
|
||||||
## Custom Content Type icons | ||||||
|
||||||
To add custom icons for existing Content Types or custom Content Types in eZ Platform follow below instruction. | ||||||
|
||||||
### Configuration | ||||||
|
||||||
A configuration of the default icon for Content Type is possible via `default-config` key. | ||||||
For example: | ||||||
|
||||||
```yaml | ||||||
ezpublish: | ||||||
system: | ||||||
default: | ||||||
content_type: | ||||||
default-config: | ||||||
thumbnail: '/assets/images/mydefaulticon.svg' | ||||||
``` | ||||||
|
||||||
Configuration of a custom icon will be exactly the same, you just need to replace default-config key with a Content Type identifier. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
For example: | ||||||
|
||||||
```yaml | ||||||
ezpublish: | ||||||
system: | ||||||
default: | ||||||
content_type: | ||||||
article: | ||||||
thumbnail: '/assets/images/customicon.svg' | ||||||
``` | ||||||
|
||||||
### Custom icons in Twig templates | ||||||
|
||||||
Content Type icons are accessible in Twig templates via `ez_content_type_icon` function. | ||||||
It requires Content Type identifier as an argument. Function returns path to a Content Type icon. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
```twig | ||||||
<svg class="ez-icon ez-icon-{{ contentType.identifier }}"> | ||||||
<use xlink:href="{{ ez_content_type_icon(contentType.identifier) }}"></use> | ||||||
</svg> | ||||||
``` | ||||||
|
||||||
If the icon for given Content Type is **not specified** in the configuration the default icon will be returned. | ||||||
|
||||||
### Custom icons in JavaScript | ||||||
|
||||||
Content Types icons configuration is stored in a global object: `eZ.adminUiConfig.contentTypes`. | ||||||
|
||||||
You can easily retrieve icon URL with a helper function `getContentTypeIcon`, set on a global object `eZ.helpers.contentType`. | ||||||
It takes Content Type identifier as an argument and returns: | ||||||
|
||||||
- URL of given Content Type's icon or | ||||||
- `null` if there is no Content Type with given identifier | ||||||
|
||||||
Example with `getContentTypeIcon`: | ||||||
|
||||||
```React JSX | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||||
const contentTypeIconUrl = eZ.helpers.contentType.getContentTypeIconUrl(contentTypeIdentifier); | ||||||
return ( | ||||||
<svg className="ez-icon"> | ||||||
<use xlinkHref={contentTypeIconUrl} /> | ||||||
</svg> | ||||||
) | ||||||
``` | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would rewrite this part to something like: Content Types icons configuration is stored in global object: You can easily retrieve icon url with helper function Example:const contentTypeIconUrl = eZ.helpers.contentType.getContentTypeIconUrl(contentTypeIdentifier);
return (
<svg className="ez-icon">
<use xlinkHref={contentTypeIconUrl} />
</svg>
); |
||||||
|
||||||
## Workflow event timeline | ||||||
|
||||||
[Workflow event timeline](workflow.md) is used out of the box to display workflow transitions. | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.