pppws Posted September 28, 2017 Share Posted September 28, 2017 hey there, i know it's a kind of dumb question, but… is it possible to duplicate the "name" field in the backend and output the whole page URL in the input? i know that i can copy the link when right clicking on it, but just a input field with the whole URL would be more comfortable (in this case). the second field (ES) illustrates what i mean. thanks for any help! Link to comment Share on other sites More sharing options...
hheyne Posted October 23, 2017 Share Posted October 23, 2017 Hi pppws, you can do this by defining an extra field e.g. URL as textfield. The you can implement a hook which saves the URL of the page into this field. I've done this for one project. This code can be used within the hellword Module. It's very simple. It saves the URL into the field shortname and fullurl when the user saves the page. In my project the field is locked, but you can define it the way you want. I hope this helps. public function init() { // add a hook after the $pages->save, to issue a notice every time a page is saved $this->pages->addHookBefore('save', $this, 'example1'); } public function example1($event) { $page = $event->arguments[0]; if($page->template->name!="presse-post" && $page->template->name!="presse-postev" ) return; $page->shortname = wire( "sanitizer" )->pageName( $page->shortname, Sanitizer::translate ); $page->fullurl = wire( 'pages' )->get( "/presse/" )->httpUrl() . "r/" . $page->shortname; } Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now