Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InputfieldPage - mark unpublished pages #2044

Open
flipzoom opened this issue Feb 13, 2025 · 0 comments
Open

InputfieldPage - mark unpublished pages #2044

flipzoom opened this issue Feb 13, 2025 · 0 comments
Labels

Comments

@flipzoom
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants