-
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
Conversation
MagdalenaZuba
commented
Jan 30, 2019
Question | Answer |
---|---|
JIRA Ticket | ezsystems/ezplatform-admin-ui#804 (comment) |
Versions | master |
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.
Two missing notes:
- Icons should be in SVG format (at least for the admin siteaccesses)
- Configuration is siteaccess aware
docs/guide/extending_ez_platform.md
Outdated
|
||
### Configuration | ||
|
||
A configuration of the default icon for Content Type is possible via default-config key. |
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.
A configuration of the default icon for Content Type is possible via default-config key. | |
A configuration of the default icon for Content Type is possible via `default-config` key. |
docs/guide/extending_ez_platform.md
Outdated
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 custom one. |
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.
Configuration of a custom icon will be exactly the same, you just need to replace default-config key with a custom one. | |
Configuration of a custom icon will be exactly the same, you just need to replace default-config key with a content type identifier. |
docs/guide/extending_ez_platform.md
Outdated
### Custom icons in Twig templates | ||
|
||
Content Type icons are accessible in Twig templates via `ez_content_type_icon` function. | ||
It requires Content Type or 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 comment
The reason will be displayed to describe this comment to others. Learn more.
It requires Content Type or Content Type Identifier as an argument. Function returns path to a Content Type icon. | |
It requires Content Type Identifier as an argument. Function returns path to a Content Type icon. |
docs/guide/extending_ez_platform.md
Outdated
</svg> | ||
``` | ||
|
||
If the icon for given Content Type is not specified in the configuration then path to the default icon will be returned. |
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.
If the icon for given Content Type is not specified in the configuration then path to the default icon will be returned. | |
If the icon for given Content Type is not specified in the configuration then default icon will be returned. |
docs/guide/extending_ez_platform.md
Outdated
system: | ||
default: | ||
content_type: | ||
default-config: |
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.
default-config: | |
article: |
<use xlinkHref={contentTypeIcon} /> | ||
</svg> | ||
); | ||
``` |
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.
I would rewrite this part to something like:
(more or less, I'm bad writer, so you can change if you feel that something is not smooth :) )
Content Types icons configuration is stored in global object: eZ.adminUiConfig.contentTypes
.
You can easily retrieve icon url with helper function getContentTypeIconUrl(contentTypeIdentifier)
, set on global object eZ.helpers.contentType
. It takes Content Type Identifier as an argument and returns url of given content type's icon or null
in case there is no content type with given identifier.
Example:
const contentTypeIconUrl = eZ.helpers.contentType.getContentTypeIconUrl(contentTypeIdentifier);
return (
<svg className="ez-icon">
<use xlinkHref={contentTypeIconUrl} />
</svg>
);
docs/guide/extending_ez_platform.md
Outdated
@@ -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. |
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.
To add custom icons for existing Content Types or custom Content Types in eZ Platform follow below instruction. | |
To add custom icons for existing Content Types or custom Content Types in eZ Platform follow the instructions below. |
docs/guide/extending_ez_platform.md
Outdated
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 comment
The reason will be displayed to describe this comment to others. Learn more.
Configuration of a custom icon will be exactly the same, you just need to replace default-config key with a Content Type identifier. | |
Configuration of a custom icon will be exactly the same, you just need to replace the `default-config` key with a Content Type identifier. |
docs/guide/extending_ez_platform.md
Outdated
### 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 comment
The reason will be displayed to describe this comment to others. Learn more.
It requires Content Type identifier as an argument. Function returns path to a Content Type icon. | |
It requires Content Type identifier as an argument. The function returns the path to a Content Type icon. |
docs/guide/extending_ez_platform.md
Outdated
|
||
Example with `getContentTypeIcon`: | ||
|
||
```React JSX |
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.
React jsx
is not recognised as a language and breaks rendering. jsx
might work.