Is it possible to add a custom field in the sorting table?

Created on 28 October 2024, about 2 months ago

I have tested to add a row in buildRow function on NodeOrderListBuilder.php.
$row['field'] = ['#markup' => $this->field_custom-value()];

Something like that, but this is not working of course.

The reason for this hack is that I have a site with lot of nodes with same titlenames.

πŸ’¬ Support request
Status

Active

Version

3.0

Component

Code

Created by

πŸ‡ΈπŸ‡ͺSweden svena

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @svena
  • @svena, there is no such possibility. The only solution at the moment is to override the NodeOrderListBuilder with your own and add custom fields there.

    Check these methods:

    • \Drupal\nodeorder\NodeOrderListBuilder::buildRow
    • \Drupal\nodeorder\NodeOrderListBuilder::buildHeader

    There is an issue in the core that is not resolved yet ✨ 3rd-party should be able to alter the EntityListBuilder rows Needs work .

    Technically, as a temporary solution, I can add hooks that will allow data modification.

  • πŸ‡ΈπŸ‡ͺSweden svena

    OK, but I am a frontender....this could be tricky for me.
    I have tested this in buildrow() function.
    $row['field_custom']['data']= [
    '#field_custom' => $entity->label(),
    ];
    I suppose I have to pick upp data first somehow.
    I know about hooks in theming but not in modules I am afraid.
    Just looking for a snippet...

Production build 0.71.5 2024