Jump to content

Add a little support for template_ids arrays in Page Reference field migrations


gornycreative
 Share

Recommended Posts

Sorry I'm working in @gebeers RepeaterMatrix fork right now, but if you could add around 3200 in RockMigrations.module.php:

(This is below the $key === "template_id" conditional test block.)

	if ($key === "template_ids") {
        foreach($val as $sub => $tpl_name) {
          if (is_string($tpl_name) and $tpl_name !== '') {
            $tpl = $this->getTemplate($tpl_name);
            if (!$tpl) throw new WireException("Invalid template_id");
            $val[$sub] = $tpl->id;
          }
          $data[$key] = $val;
          continue; // early exit
        }
      }

This would allow the 'Selectable Pages > Additional Templates' setting on Page Reference fields to migrate the 'template_ids' setting properly with template name references into of raw ids in a similar manner to the template_id setting conversion.

  • Like 2
Link to comment
Share on other sites

When you have a Page Reference inputfield, there are two different template options settings:

image.thumb.jpeg.80e5f39ac546e6eb2431a5f374db7285.jpeg

With the standard migrate() config array, the template_id setting gets processed fine if you use a template name instead of the template_id - the green checkmark.

The template_ids setting does not get processed if you use template names. Nothing appears.

Adding the processing block I wrote above allows template names to be used in that template_ids setting.

  • Thanks 1
Link to comment
Share on other sites

  • 1 month later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...