Last active
November 13, 2015 01:49
-
-
Save katzueno/6b2564dd1ea7f35bf135 to your computer and use it in GitHub Desktop.
[concrete5]/model/layout.php to override concrete5.6.x layout system to support Foundation & Bootstrap CSS Framework
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
defined('C5_EXECUTE') or die("Access Denied."); | |
// Bootstrap CSS Hack for concrete5.6.x | |
// Rename this file as laytout.php and place it under [concrete5]/models/ folder/ | |
class Layout extends Concrete5_Model_Layout { | |
function display( $c=NULL, $a=NULL ){ | |
if(!$c) global $c; | |
if(!$a) global $a; | |
if(!in_array($this->type,$this->layoutTypes)) $this->layoutType='table'; | |
echo '<div id="ccm-layout-wrapper-'.intval($this->cvalID).'" class="ccm-layout-wrapper">'; | |
if ($c->isEditMode()) { | |
$args = array('layout'=>$this); | |
Loader::element('block_area_layout_controls', $args); | |
} | |
//echo intval($this->cvalID).' '.$this->layoutID.'<br>'; | |
$targetArea = 0; | |
if ($a->getAreaHandle() == 'Main' || $a->getAreaHandle() == 'visitorsArea') { | |
$targetArea = 1; | |
} | |
if ($this->columns == 4 && $targetArea == 1) { | |
$this->displaySolidGrid($this->rows,$this->columns,$c,'col-sm-3'); | |
} elseif ($this->columns == 3 && $targetArea == 1) { | |
$this->displaySolidGrid($this->rows,$this->columns,$c,'col-sm-4'); | |
} elseif ($this->columns == 2 && $targetArea == 1) { | |
$this->displaySolidGrid($this->rows,$this->columns,$c,'col-sm-6'); | |
} elseif ($this->columns == 1 && $targetArea == 1) { | |
$this->displaySolidGrid($this->rows,$this->columns,$c,'col-sm-12'); | |
} else { | |
$this->displayTableGrid($this->rows,$this->columns,$c); | |
} | |
echo '</div>'; | |
} | |
protected function displaySolidGrid($rows=3,$columns=3,$c=NULL,$class=''){ | |
if(!$c) global $c; | |
if($c->isEditMode()) $editMode='ccm-edit-mode'; | |
if(!intval($rows)) $rows=1; | |
if(!intval($columns)) $columns=3; | |
$layoutNameClass = 'ccm-layout-name-'.TextHelper::camelcase($this->getAreaHandle()).'-'.TextHelper::camelcase($this->getLayoutNameTxt()).'-'.$this->getAreaNameNumber(); | |
$layoutIDVal = strtolower('ccm-layout-'.TextHelper::camelcase($this->getAreaHandle()).'-'.$this->layoutID . '-'. $this->getAreaNameNumber()); | |
for( $i=0; $i<$rows; $i++ ){ | |
echo '<div class="row '.$layoutNameClass.' '.$editMode.'">'; | |
for( $j=0; $j<$columns; $j++ ){ | |
$columnn_id = 'ccm-layout-'.intval($this->layoutID).'-col-'.($j+1); | |
echo '<div id="'.$columnn_id.'" class="'.$class.'">'; | |
$a = new Area( $this->getCellAreaHandle($this->getCellNumber()) ); | |
$a->display($c); | |
echo '</div>'; | |
} | |
echo '</div>'; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
defined('C5_EXECUTE') or die("Access Denied."); | |
// Foundation CSS Hack for concrete5.6.x | |
// Rename this file as laytout.php and place it under [concrete5]/models/ folder/ | |
class Layout extends Concrete5_Model_Layout { | |
function display( $c=NULL, $a=NULL ){ | |
if(!$c) global $c; | |
if(!$a) global $a; | |
if(!in_array($this->type,$this->layoutTypes)) $this->layoutType='table'; | |
echo '<div id="ccm-layout-wrapper-'.intval($this->cvalID).'" class="ccm-layout-wrapper">'; | |
if ($c->isEditMode()) { | |
$args = array('layout'=>$this); | |
Loader::element('block_area_layout_controls', $args); | |
} | |
//echo intval($this->cvalID).' '.$this->layoutID.'<br>'; | |
if ($this->columns == 4 && $a->getAreaHandle() == 'Main') { | |
$this->displaySolidGrid($this->rows,$this->columns,$c,'three columns'); | |
} elseif ($this->columns == 3 && $a->getAreaHandle() == 'Main') { | |
$this->displaySolidGrid($this->rows,$this->columns,$c,'four columns'); | |
} elseif ($this->columns == 2 && $a->getAreaHandle() == 'Main') { | |
$this->displaySolidGrid($this->rows,$this->columns,$c,'six columns'); | |
} elseif ($this->columns == 1 && $a->getAreaHandle() == 'Main') { | |
$this->displaySolidGrid($this->rows,$this->columns,$c,'twelve columns'); | |
} else { | |
$this->displayTableGrid($this->rows,$this->columns,$c); | |
} | |
echo '</div>'; | |
} | |
protected function displaySolidGrid($rows=3,$columns=3,$c=NULL,$class=''){ | |
if(!$c) global $c; | |
if($c->isEditMode()) $editMode='ccm-edit-mode'; | |
if(!intval($rows)) $rows=1; | |
if(!intval($columns)) $columns=3; | |
$layoutNameClass = 'ccm-layout-name-'.TextHelper::camelcase($this->getAreaHandle()).'-'.TextHelper::camelcase($this->getLayoutNameTxt()).'-'.$this->getAreaNameNumber(); | |
$layoutIDVal = strtolower('ccm-layout-'.TextHelper::camelcase($this->getAreaHandle()).'-'.$this->layoutID . '-'. $this->getAreaNameNumber()); | |
for( $i=0; $i<$rows; $i++ ){ | |
echo '<div class="row '.$layoutNameClass.' '.$editMode.'">'; | |
for( $j=0; $j<$columns; $j++ ){ | |
$columnn_id = 'ccm-layout-'.intval($this->layoutID).'-col-'.($j+1); | |
echo '<div id="'.$columnn_id.'" class="'.$class.'">'; | |
$a = new Area( $this->getCellAreaHandle($this->getCellNumber()) ); | |
$a->display($c); | |
echo '</div>'; | |
} | |
echo '</div>'; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment