Comanche: provide a variable '$region' which can be used within a layout to make content aware of where it is on the page. For instance this can be passed as a variable to a widget and trigger either a vertical or horizontal layout depending on which region it is assigned to.

This commit is contained in:
redmatrix 2016-05-12 21:18:34 -07:00
parent 522fec5763
commit 2f222546da

View File

@ -8,7 +8,6 @@ require_once('include/widgets.php');
class Comanche { class Comanche {
@ -95,7 +94,7 @@ class Comanche {
$cnt = preg_match_all("/\[region=(.*?)\](.*?)\[\/region\]/ism", $s, $matches, PREG_SET_ORDER); $cnt = preg_match_all("/\[region=(.*?)\](.*?)\[\/region\]/ism", $s, $matches, PREG_SET_ORDER);
if($cnt) { if($cnt) {
foreach($matches as $mtch) { foreach($matches as $mtch) {
\App::$layout['region_' . $mtch[1]] = $this->region($mtch[2]); \App::$layout['region_' . $mtch[1]] = $this->region($mtch[2],$mtch[1]);
} }
} }
} }
@ -320,7 +319,9 @@ class Comanche {
} }
function region($s) { function region($s,$region_name) {
$s = str_replace('$region',$region_name,$s);
$matches = array(); $matches = array();