contao icon indicating copy to clipboard operation
contao copied to clipboard

Improve label generation in DataContainer list

Open bezin opened this issue 3 years ago • 6 comments

Description

While working on #4682 I wanted to add one more information to the page label (the selected feed format) and keep everything else exactly as is: 2022-05-31 16_28_37

Since there can only be one label_callback, I have to overwrite the Core label listener, copy its implementation and keep it updated. I have no suggestion, but just wanted to leave a note. Maybe somebody has an idea on how to solve this in the future?

bezin avatar May 31 '22 14:05 bezin

there already is the getPageIcon hook, maybe we could improve that to also generate the label?

aschempp avatar Jun 01 '22 06:06 aschempp

thinking about this, if I wanted to know if a page type is RSS or JSON, I could simply add that information to the page title, right? Since the title is not seen/used anywhere in this case anyway?

aschempp avatar Jun 01 '22 06:06 aschempp

there already is the getPageIcon hook, maybe we could improve that to also generate the label?

I already use this to add the icon. What do you suggest?

thinking about this, if I wanted to know if a page type is RSS or JSON, I could simply add that information to the page title, right? Since the title is not seen/used anywhere in this case anyway?

The page title is part of the feed (e.g. <title></title> in RSS), so I would like to treat the format as metadata and display it separately.

bezin avatar Jun 01 '22 07:06 bezin

Regardless of how to improve this: this new functionality is part of the core - so you can implement it in the existing callback anyway.

fritzmg avatar Jun 01 '22 07:06 fritzmg

The new functionality is part of the news bundle (the calendar bundle respectively), but the label callback is part of the core bundle.

bezin avatar Jun 01 '22 07:06 bezin

What about allowing multiple label callbacks and an is_array() check to remain backwards compatible?

leofeyer avatar Oct 05 '22 14:10 leofeyer

What about allowing multiple label callbacks and an is_array() check to remain backwards compatible?

I don't think we can usefully apply multiple labels anywhere in the DCA, since you can never know what has been added before. It would probably work in this edge case where you just want to append something, but that might not always be the case.

This is a special case for page titles, the label should be rendered individually for each page type. We already have a hook for the icon, maybe we should just have a hook/event to generate the title for a page (including the icon)?

aschempp avatar Nov 02 '22 06:11 aschempp

As discussed in the Contao call, we want to allow multiple label callbacks. We also want to make the label generation template based with the template output being passed to the label callback chain.

leofeyer avatar Jan 12 '23 14:01 leofeyer