Skip to content

[RFC] - Render Elements Event #6023

@leevigraham

Description

@leevigraham

Description

Add an event to override rendering of elements.

Proposed Implementation:

  1. Create a new RenderElementEvent which gets called in vendor/craftcms/cms/src/base/Element.php

image

  1. Allow modification in plugins / modules of the template path:

image

  1. Override the template in local module:

modules/mytikilife/src/templates/_elements/tableview/container.twig

image

modules/mytikilife/src/templates/_elements/tableview/elements.twig
image

Result:

2020-05-05 13 41 54

This hook would not be for the faint of heart and could easily break a lot of functionality. In my use case I'm checking for the source and a few other things before overriding the templates.

One other small change was passing the $source into the $elementType::indexHtml() method so it could be passed into the Event.

image

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementimprovements to existing featuresextensibility 🔌features related to plugin/module dev

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions