Jump to content

[SOLVED] How to copy title in multi language?


Flashmaster82
 Share

Recommended Posts

Hello,

Example in ready.php:

$this->addHookBefore('Pages::saveReady()',
    function (HookEvent $event): void {

        /** @var Page $page */
        $page = $event->arguments(0);

        $default = wire()->languages->get("default");
        $english = wire()->languages->get("english");

        $page->of(false);

        /** @var LanguagesPageFieldValue $field */
        $field = $page->title;
        $defaultTitle = $field->getLanguageValue($default);

        if ($defaultTitle && !$field->getLanguageValue($english))
            $field->setLanguageValue($english, $defaultTitle);

        $page->of(true);
    }
);

 

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

  • Flashmaster82 changed the title to [SOLVED] How to copy title in multi language?

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

×
×
  • Create New...