Jump to content

Weekly update – 5 April 2024


Recommended Posts

On the dev branch this week are a few issue fixes, but also some new features. The "Parent" field in the page editor (Settings tab) now is contextual to the page's template family settings. Now it will just show you the allowed parents, if you've configured them in the template. Previously it would show you a page tree to select from anywhere in the site. This saves you time, as well as the hassle of getting an error message after save, should you select a parent that isn't allowed by the page's template family settings. 

image.png

Next, the page tree "Move" actions (that you see when hovering a page in the tree) are now a little smarter. Previously, these Move actions would appear for any page that was either sortable or moveable. But now it also checks how many other allowed parents there are, per template family settings. If there aren't yet any other potential parent pages existing in the site, the page is no longer considered moveable, and thus won't show a Move action. This useful addition was added per Bernhard's request, as was the addition to a couple new classes used in the page tree to better differentiate between public vs non-public pages... something that I understand Bernhard's admin style may soon demonstrate. 

This week a question came up through email about how to make multi-language "required" fields require a value in all languages the page is active in. Currently multi-language required fields only require a value to be present in the default language. If you want to make them require all active languages, you can do so with a hook in /site/ready.php. I thought it was pretty useful so thought I'd share it here. Though maybe we'll have to add it as a feature. 

if($page->process == 'ProcessPageEdit') {
  $wire->addHookAfter('Inputfield(required=1,useLanguages=1)::processInput', function($event) {
    $inputfield = $event->object;
    $page = $inputfield->hasPage;
    if(!$page) return;
    foreach($event->wire()->languages as $language) {
      if($language->isDefault()) continue;
      if(!$page->get("status$language")) continue; // skip languages not active on page
      $value = $inputfield->get("value$language");
      if(empty($value)) {
        $inputfield->error("Value required for language " . $language->get('title|name'));
      }
    }
  });
}


 

  • Like 17
  • Thanks 1
Link to comment
Share on other sites

1 hour ago, ryan said:

But now it also checks how many other allowed parents there are, per template family settings. If there aren't yet any other potential parent pages existing in the site, the page is no longer considered moveable, and thus won't show a Move action.

Just to add to this: the Move action is only removed if there is a "Children are sorted by" setting on the parent template or the parent page.

image.png.5df095d2b7c0cb3259ce6920f7f8ec3a.png

image.png.afca3199a1ba96b4e7909d3d6df4665e.png

Because even if there are no other allowed parents, the Move action is present to allow sorting within the existing parent so long as no fixed sorting is set.

  • Like 3
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...