Skip to content

Commit

Permalink
Added integration of rocksolid-columns
Browse files Browse the repository at this point in the history
  • Loading branch information
ausi committed Nov 5, 2013
1 parent 29374c1 commit 9c8a6bc
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/MadeYourDay/Contao/CustomElements.php
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,9 @@ protected function createDca($dc, $type, $createFromPost = false, $tmpField = nu
if (in_array('headline', $standardFields)) {
$GLOBALS['TL_DCA'][$dc->table]['palettes'][$type] .= ',headline';
}
if (in_array('columns', $standardFields)) {
$GLOBALS['TL_DCA'][$dc->table]['palettes'][$type] .= ';{rs_columns_legend},rs_columns_large,rs_columns_medium,rs_columns_small';
}
if (in_array('text', $standardFields)) {
$GLOBALS['TL_DCA'][$dc->table]['palettes'][$type] .= ';{text_legend},text';
}
Expand Down
25 changes: 25 additions & 0 deletions src/MadeYourDay/Contao/Element/CustomElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ public function compile()
$this->Template->getImageObject = function() use($self) {
return call_user_func_array(array($self, 'getImageObject'), func_get_args());
};
$this->Template->getColumnClassName = function() use($self) {
return call_user_func_array(array($self, 'getColumnClassName'), func_get_args());
};
}

/**
Expand Down Expand Up @@ -182,4 +185,26 @@ public function getImageObject($id, $size = null)
$this->addImageToTemplate($imageObject, $image);
return $imageObject;
}

/**
* Get the column class name for the specified index
*
* @param int $index Index of the column
* @return string Class name(s)
*/
public function getColumnClassName($index)
{
if (!class_exists('MadeYourDay\\Contao\\Element\\ColumnsStart')) {
return '';
}

$config = ColumnsStart::getColumnsConfiguration($this->arrData);

$classes = array('rs-column');
foreach ($config as $media) {
$classes = array_merge($classes, $media[$index % count($media)]);
}

return implode(' ', $classes);
}
}

0 comments on commit 9c8a6bc

Please sign in to comment.