function AbsoluteLink($master = false) { $page = $master ? Dataobject::get_by_id("SiteTree", $this->MasterPageID) : Dataobject::get_by_id("SiteTree", $this->RelatedPageID); if (!$page) { return; } $url = $page->AbsoluteLink(); }
public function testSaveIntoManyManyRelation() { $article = $this->objFromFixture('ListboxFieldTest_Article', 'articlewithouttags'); $articleWithTags = $this->objFromFixture('ListboxFieldTest_Article', 'articlewithtags'); $tag1 = $this->objFromFixture('ListboxFieldTest_Tag', 'tag1'); $tag2 = $this->objFromFixture('ListboxFieldTest_Tag', 'tag2'); $field = new ListboxField("Tags", "Test field", DataObject::get("ListboxFieldTest_Tag")->map()->toArray()); $field->setMultiple(true); // Save new relations $field->setValue(array($tag1->ID, $tag2->ID)); $field->saveInto($article); $article = Dataobject::get_by_id('ListboxFieldTest_Article', $article->ID, false); $this->assertEquals(array($tag1->ID, $tag2->ID), $article->Tags()->sort('ID')->column('ID')); // Remove existing relation $field->setValue(array($tag1->ID)); $field->saveInto($article); $article = Dataobject::get_by_id('ListboxFieldTest_Article', $article->ID, false); $this->assertEquals(array($tag1->ID), $article->Tags()->sort('ID')->column('ID')); // Set NULL value $field->setValue(null); $field->saveInto($article); $article = Dataobject::get_by_id('ListboxFieldTest_Article', $article->ID, false); $this->assertEquals(array(), $article->Tags()->sort('ID')->column('ID')); }