Add Element::getElementHtml()
to allow elements to define their own HTML for the element icon
#11035
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
For Comments and Navigation plugins we want to show a little extra information against the title/status of an element, in their element index. Shown as below:
For Navigation, we actually just want to append some icons to the element's icon/pill (there must be a name for that?)
For Comments, we actually want to be a bit more hands-on, by adding a snippet of their comment.
Right now, the only way to achieve this is through the
cp.elements.element
, checking against the element type is the one we want, and modifying it. It's not amazing, but it works.One thing that doesn't work is when modifying the element with the new element side-out pane. For instance, with Navigation, there's a new-window icon that shows up when you enable that for the element. This won't change when the slide-out is closed, because the Twig hook isn't run, instead
Cp::elementHtml()
is.I've also opted to modify just the
$innerHtml
of the element icon thing - because of the wayCraft.BaseElementIndex
works, it'll be looking for a.element
div
, to swap out with JS. If we append things outside of that (like I am currently doing with Navigation), then it gets messy. As such, anything modifiable, should really be contained within the.element
div
.As such, I'm using a modify-style handling here, instead of straight replacing of what
Cp::elementHtml()
does. So I can still grab the stock HTML generated and add my own, or replace it entirely.Keen to get your thoughts.