Search the Community
Showing results for tags 'autopopulate'.
-
Hi I'm working with PW for some time now, but – please don't laugh – never used hooks. I have 200 – 300 subpages with the template 'artist', the title of each page represents the full name, sometimes John Doe, sometimes John Emmet Brown Doe. I want to auto-populate the field 'artist_last_name' with the word that is most likely the last name, the last word of the page title. If there are more names, it can be changed manually. I need this for easier and quicker alphabetical sorting. What I put together is this, in ready.php. Doesn't work. Again, I'm new to hooks.. <?php $wire->addHookBefore('Pages::saved', function(HookEvent $event) { $p = $event->arguments('page'); if($p->template != 'artist') return; if($p->artist_last_name) return; $ln = end(explode(' ', $p->title)); $p->set('artist_last_name',$ln); }); ?> In the best case this would be done once globally without having to open and save every page. But new pages should populate the field on page save. Thanks for your help, I think it's easy, I just need a push.. Nuél
-
Mod Note: Topic locked. Please see this post instead, thanks. Hi, Anybody know if it is possible to autopopulate a leaflet "address" from another field on a template ? I have a country template, user enters a country name, then unfortunately needs to enter country name again to get the map. Would be much better if it auto populated.
- 1 reply
-
- autopopulate
- address field
-
(and 1 more)
Tagged with: