getkirby-v2 / plugins

Kirby plugins from getkirby.com. Extensions, fields and widgets
230 stars 5 forks source link

Kirby UpdateID #531

Open pqml opened 6 years ago

pqml commented 6 years ago

Github: https://github.com/brocessing/kirby-updateid

Sometimes you need to reference pages to each other, usually by the page ID When you update a page URI, the ID can change and references to this page from other page/fields can be lost. This plugin automatically updates selected fields when a referenced ID change.

Example
c::set('plugin.updateid', array(
  // On the homepage, page ids from the field featured_works will be auto-updated
  array(
    'pages'  => 'home',
    'fields' => 'featured_works'
  ),
  // Auto-update client page id on each project page
  array(
    'pages'  => function () { return site()->find('work')->children(); },
    'fields' => 'client'
  )
));