This works quite well.
The Idea is this.
When you use category, tags and stuff to organize your content, you don´t
get a clear view of what is happening to your content and you don´t have
the ability to organize it on each level( change content, sort order, style etc…)
Well now you can… It is very powerful in the meaning of full control.
For an example :
First you define your structure:
Home > Sport > Fotball > England > Premier League
Then you do your “post” (Arsenal) :
Home > Sport > Fotball > England > Premier League > Arsenal
In my case I have 2 checkboxes that define the page. If it´s a
"Archive" or a “post”. All parents pages with Archive “checked” will get
the post “Arsenal”.
Then if you for instance want to save the hole post “thread” in one go,
I have 1 “frontsave” and 1 “backsave”. I have one field for how the post will
display when it is a child of a page and 1 when you are on actually page.
So if you check the “frontsave” and hit the save button it will update all posts on each
level in one go… This is kind of nice, In cases you don´t need to display the post different on every level…
In your “create, update” array you put all your fields.
Hope this make some sense ; )
It ´s in beta mode so, the code is probably not the best and most effective,
hope you guys find it interesting and are willing to collaborate on it.
Your Monk.
class PagerField extends BaseField {
public function template() {
$page = $this->page();
$site = site();
if($page->pager() == '1' && $page->isVisible()) {
foreach($page->parents()->visible() as $parent) {
if ($parent->archive() == '1') {
try {
$ID = (string)$page->uid();
$order = $parent->children()->visible()->count() + 1;
$newPage = $parent->children()->create($ID, 'page', array(
'title' => $page->title(),
'fronttext' => $page->fronttext(),
'backtext' => $page->backtext()
));
$newPage->sort($order);
} catch(Exception $e) {
continue;
}
}
}
}
if($page->frontsave() == '1') {
foreach($site->index()->visible() as $child) {
if($page->uid() == $child->uid()) {
try {
$child->update(array(
'fronttext' => $page->fronttext()
));
} catch(Exception $e) {
continue;
}
}
}
}
if($page->backsave() == '1') {
foreach($site->index()->visible() as $child) {
if($page->uid() == $child->uid()) {
try {
$child->update(array(
'backtext' => $page->backtext()
));
} catch(Exception $e) {
continue;
}
}
}
}
}