Skip to content

Instantly share code, notes, and snippets.

Created October 25, 2016 09:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/012e5309b9b69434c25864f176177aca to your computer and use it in GitHub Desktop.
Save anonymous/012e5309b9b69434c25864f176177aca to your computer and use it in GitHub Desktop.
// Shortcode to add Items (add layout to the page)
public static function ShortcodeItem($arguments, $content = null, $parser = null, $tagName) {
$item = new ArrayList();
$item->Content = DBField::create('HTMLText', $content);
if (isset($arguments['size']) && $arguments['size'] != '') {
$item->Size = $arguments['size'];
} else {
$item->Size = '2';
}
if (isset($arguments['first'])) {
$item->Style = 'margin-left: 0; padding-left: 0;';
}
if (isset($arguments['last'])) {
$item->Style = 'margin-right: 0; padding-right: 0;';
}
if (isset($arguments['position']) && $arguments['position'] !== '') {
$position = $arguments['position'];
if ($position == 'right') {
$item->PositionStyle = 'float: right;';
$item->Style = 'margin-right: 0; padding-right: 0;';
} elseif ($position == 'center') {
$item->PositionStyle = 'float: none; clear: both; margin-left: auto; margin-right: auto;';
}
}
if (isset($arguments['CustomClass']) && $arguments['CustomClass'] !== ''){
$item->CC = $arguments['CustomClass'];
}
if (isset($arguments['offset']) && $arguments['offset'] !== ''){
$item->OSize = $arguments['offset'];
}
return $item->renderWith(array('Shortcodes', 'Item'));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment