From 74582630177b104f35113cee77d2c7ac5f74f412 Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 29 Aug 2013 20:54:42 -0700 Subject: I've got a pretty good idea of how to bootstrap, parse and render Comanche now. This does not mean it's close to being presentable - far from it. --- boot.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'boot.php') diff --git a/boot.php b/boot.php index a5ff7ea0b..5e8b52d0d 100755 --- a/boot.php +++ b/boot.php @@ -2386,6 +2386,7 @@ function get_custom_nav(&$a,$navname) { function construct_page(&$a) { + require_once('include/comanche.php'); $comanche = ((count($a->layout)) ? true : false); @@ -2434,9 +2435,23 @@ function construct_page(&$a) { $a->page[$x['location']] .= $x['html']; } } + + // Let's say we have a comanche declaration '[region_nav][/region_nav][region_content]$region_nav $region_section[/region_content]'. + // The text 'region_' identifies a section of the layout by that name (without the 'region_' text). + // So what we want to do here is leave $a->page['nav'] empty and put the default content from $a->page['nav'] and $a->page['section'] + // into a new region called $a->data['content']. It is presumed that the chosen layout file for this comanche page + // has a '' element instead of a '
'. + + // This way the Comanche layout can include any existing content, alter the layout by adding stuff around it or changing the + // layout completely with a new layout definition, or replace/remove existing content. + if($comanche) { foreach($a->layout as $k => $v) { - if(strpos($k,'region_') === 0) { + if((strpos($k,'region_') === 0) && strlen($v)) { + if(strpos($v,'$region_') !== false) { + $v = preg_replace_callback('/\$region_([a-zA-Z0-9]*?)/ism','comanche_replace_region',$v); + + } $a->data[substr($k,0,7)] = $v; } } -- cgit v1.2.3