ProcessWire新建页面默认启用多语言URL选项

$this->pages->addHookBefore('setupNew', function(HookEvent $event) {

	$page = $event->arguments[0];

	if(!strlen(trim($page->name)) && $page->id != 1){
		$page->name = $this->pages->find("include=all, sort=-id, limit=1")->first()->id+1;
	}

	foreach ($this->wire->languages as $lang) $page->set("status$lang", 1);

});

Post Comment