javascript - What would be the simplest way to automatically have the URL segment updated? -
this question url update feature when changing value of page
title
field. behaviour coded cmsmain.editform.js.
i'm stripping down , customising cms usable absolute basic computer user or negligent client, skip pressing update url button upon page name change. in these cases convenient if urlsegment
automatically updated.
q: simplest way automatically have url segment updated, ie simulate result appear upon clicking "update url" button, after changing title
field?
you make extension sitetree , include function onbeforewrite this. make change if updated title , not url:
class autourlsync extends extension { public function onbeforewrite() { // if title changed, urlsegment not, // update urlsegment here if($this->owner->ischanged('title',2) && !$this->owner->ischanged('urlsegment',2)) { $this->owner->urlsegment = $this->owner->generateurlsegment($this->owner->title); } } }
removing "if" mean changed.
add in _config/config.yml
link extension:
sitetree: extensions: - autourlsync
Comments
Post a Comment