anewt-developers team mailing list archive
-
anewt-developers team
-
Mailing list archive
-
Message #00318
[Branch ~uws/anewt/anewt.uws] Rev 1823: [page] Don't make append() depend on the 'blocks' property
------------------------------------------------------------
revno: 1823
committer: Wouter Bolsterlee <uws@xxxxxxxxx>
branch nick: anewt
timestamp: Thu 2011-03-17 17:21:49 +0100
message:
[page] Don't make append() depend on the 'blocks' property
AnewtPage->append() shouldn't depend on the 'blocks'
property to decide which block to append to. Instead, use
the 'default-block' property. This allows custom pages that
override build_body() to still use blocks as before, but
without using the default "list of <div> elements in a
wrapper" implementation that AnewtPage provides.
modified:
page/page.lib.php
--
lp:anewt
https://code.launchpad.net/~uws/anewt/anewt.uws
Your team Anewt developers is subscribed to branch lp:anewt.
To unsubscribe from this branch go to https://code.launchpad.net/~uws/anewt/anewt.uws/+edit-subscription
=== modified file 'page/page.lib.php'
--- page/page.lib.php 2011-03-17 16:17:53 +0000
+++ page/page.lib.php 2011-03-17 16:21:49 +0000
@@ -253,20 +253,11 @@
*/
public function append($new_child)
{
- if ($this->_get('blocks'))
- {
- /* This is a block-based page */
-
- $default_block_name = $this->_get('default-block');
-
- if (is_null($default_block_name))
- throw new AnewtException('AnewtPage::append() can only be used on block-based pages if a default block is set.');
-
- $this->append_to($default_block_name, $new_child);
-
- } else
- {
- /* This is a simple page */
+ $default_block_name = $this->_get('default-block');
+
+ if (is_null($default_block_name))
+ {
+ /* Assume this is a simple page */
if (!$this->_content)
$this->_content = new AnewtXMLDomDocumentFragment();
@@ -276,6 +267,14 @@
else
$this->_content->append_child($new_child);
}
+ else
+ {
+ /* This page has content blocks; either the 'blocks' property is
+ * set, or a derived class provides a custom build_body()
+ * implementation */
+
+ $this->append_to($default_block_name, $new_child);
+ }
}
/**