Skip to content

Instantly share code, notes, and snippets.

@teppokoivula
Created February 22, 2014 09:19
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
<?php
// Bootstrap ProcessWire
require "index.php";
// Install LanguageSupportFields (unless already installed)
if (!wire('modules')->isInstalled('LanguageSupportFields')) {
wire('modules')->install('LanguageSupportFields');
}
// Create new multi-language textfield and add it to basic-page template
$field = new Field;
$field->type = wire('modules')->get('FieldtypeTextLanguage');
$field->name = 'text_language';
$field->save();
$fieldgroup = wire('fieldgroups')->get('basic-page');
$fieldgroup->add($field);
$fieldgroup->save();
// Create new page and assign value to multi-language textfield
$page = new Page;
$page->parent = wire('pages')->get('/');
$page->template = wire('templates')->get('basic-page');
$page->title = "a test page";
$page->text_language->setLanguageValue(wire('languages')->get('default'), 'test');
for ($i=0; $i<5; ++$i) {
if ($page->isChanged()) {
echo "* changed ($i)\n";
$page->save();
}
}
// Remove page
$page->delete();
// Remove field
$fieldgroup->remove($field);
$fieldgroup->save();
wire('fields')->delete($field);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment