Skip to content

InputfieldPage - mark unpublished pages #2044

Open
@flipzoom

Description

@flipzoom

I have now come across the scenario a few times where the UX with the InputfieldPage field is not optimal.

An example of the InputfieldPageListSelectMultiple. If the option ‘Allow unpublished pages’ is activated, the user unfortunately cannot see which page has which status. Example:

Image

It would be nice if the unpublished pages were labelled when this option is active. Both in the title and with a CSS class for styling. Example:

Image

So far I solve this with a HookAfter on InputfieldPageListSelectMultiple::render and simply add the two lines of code:

// ...
foreach($field->value as $page_id) {
        $page = $field->pages->get((int) $page_id); 
        if(!$page || !$page->id) continue; 
        $label = $page->getText($field->labelFieldName, true, true);
        if(!strlen($label)) $label = $page->name;
        if($page->isUnpublished()) $label .= " <small>({$this->_('unpublished')})</small>"; // @CUSTOM - Add unpublished label
        $class = ($page->isUnpublished()) ? "is-unpublished" : ""; // @CUSTOM - Add unpublished class
        $out .= $field->renderListItem($label, $page->id, $class); // @CUSTOM - Add $class
}
// ...

But there are also other InputPage selects and I don't really want to create a hook for every mode. Can you set the labelling by default? Also for Radio, ASMSelect, Page Autocoplete etc.?

Background: pages are linked, for example, but are published and unpublished on a time-controlled basis. However, as already mentioned, the editor cannot recognise which of the linked pages has which status.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions