Skip to content

Instantly share code, notes, and snippets.

@arjenblokzijl
Created July 8, 2014 18:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arjenblokzijl/1fefecf1a4c8841cfaf8 to your computer and use it in GitHub Desktop.
Save arjenblokzijl/1fefecf1a4c8841cfaf8 to your computer and use it in GitHub Desktop.
Simple script to convert Page field to Pagetable
<?php
include("index.php");
$pages = wire()->pages;
$stadiums = $pages->find("template=template, field.count>0");
$ptf = "template";
$ptt = "fieldname";
$name = "name";
foreach($stadiums as $stadium)
{
$count = 0;
foreach($stadium->architect as $architect)
{
$count++;
$npt = new Page();
$npt->of(false);
$npt->name = $name . "-" . $count;
$npt->template = $ptt;
$npt->parent = $stadium;
$npt->architect = $architect;
$npt->save();
}
$stadium->of(false);
$stadium->$ptf->add($npt);
$stadium->save();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment