Sorry, we don't support your browser.  Install a modern browser

Structure: custom columns#285

For some columns, for nicer overview experience, it would be nice to add not only structure fields as a columns, but a result of PHP helpers (KQL?) as well.

For instance: Right now I have a structure field which can either have two fields filled, or third field filled. Let’s call them Hours, Minutes, Price. I’d Like to have a column in the overview that’s either set to {Hours}:{Minutes} or {Price}. if I had access to site methods (or custom methods, or whatever), I could easily do it with one if and two returns.

The only option I see now as possible is creating a new panel field, which is hidden while editing, but outputs hardwired code while in preview.

Thank you

Note: This is possibly the same as #121, but I’m not 100% sure

3 years ago

Handling this on the backend is unfortunately not viable as all the data is only present in the frontend (as long as you don’t save the changes, the backend doesn’t know about the field values). So the Panel would need to send an API request for every single structure item.

Maybe we can improve the blueprint configuration to allow custom columns that contain placeholders for multiple fields. But once logic is involved like in your example, plugin JS code seems to be the only option.

3 years ago
1

@Lukas Bestle That is unfortunate, but understandable. Do you think something like “compound columns”*, but only for saved structure items would be possible? e.g. show ‘––’ for new and changed items, but use the PHP result for ones PHP knows about and haven’t changed?

I’ll understand if there are issues I’m not seeing. Possibly even “might be hard to properly communicate state” why it sometimes work and sometimes shows just ‘––’ is a valid problem.

  • that’s what I’m calling this now
3 years ago

@Nico What do you think?

3 years ago

I’m wondering if it wouldn’t make a lot of sense to have a new API call that refreshes the data when a row gets updated/save (not the field, and so also not updating the content file).

3 years ago

@Nico for other, unrelated things as well? Just have a “structure->refresh()” call or whatever?

3 years ago

@Adam not as $structure->refresh() that’s backend, we need to trigger the API call once a row gets update in the Panel, so that it updates its data e.g. about the columns with the current unsaved changes.

Tbh I am a bit hesitant to proceed with anything here though. I feel like we need to tackle first the state of unsaved changes, that needs larger improvements.

3 years ago

I agree. It would be awesome to have the unsaved changes mirrored on the backend for several other reasons (backup in case the client forgets its localStorage, continuation by other Panel users…). If we had that, we could easily solve this as well.

3 years ago