Created
July 8, 2014 18:17
-
-
Save arjenblokzijl/1fefecf1a4c8841cfaf8 to your computer and use it in GitHub Desktop.
Simple script to convert Page field to Pagetable
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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