2

Is there a way to add a column to the control panel display of entries? I would strongly prefer to not write a plug-in for this. The contents in the column would be nothing more than a button that links to a URL containing the UID of the entry. Note, I am not using the Commerce plug-in here.

If I have to write a plug-in, what would be the simplest scaffold to use?

enter image description here

1 Answer 1

3

A simple-ish way you could do this is by using the pre-parse field to parse {{ entry.uid }}.

This will then give you an extra column with the unique ID. You can then use Control panel JS to change that into a link/create a button. Something like:

$(document).ready(function() {
    Craft.elementIndex.on('updateElements ', function(data){
        if (data.target.$source.data('handle') == 'your-section-handle') {
            $('td[data-attr=field:your-field-id]').each(function(){
                <!-- JS code to change uid into link -->
            });
        }
    });
});

Replacing your-section-handle and your-field-id.

2
  • Of course, there already is a UID column – so you could just use that instead of Pre-parse.
    – dmatthams
    Jul 23, 2021 at 9:40
  • Thanks, dmatthams. If I put the correct section handle and field ID in place, with no extra code, should this run without issue? I decided to just target the entry ID field (id), because I can build my button from that. $(document).ready(function() { Craft.elementIndex.on('updateElements ', function(data){ if (data.target.$source.data('handle') == 'test') { $('td[data-attr=field:id]').each(function(){ // }); } }); });
    – 4midori
    Jul 23, 2021 at 17:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.