Skip to content

Instantly share code, notes, and snippets.

Created November 22, 2016 14:22
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/9d1452418c63db8df1c8e111e31e4a57 to your computer and use it in GitHub Desktop.
Save anonymous/9d1452418c63db8df1c8e111e31e4a57 to your computer and use it in GitHub Desktop.
// View
<% loop ItemBlocks %>
<% if $Up.ShortCodeClass = $DatabaseClass %>
<div class="item <% if $Up.Size %> item-$Up.Size $Up.CC<% else %> item-1 <% end_if %> item-block">
<div class="inner">
<% if ItemImage %>
$ItemImage
<% end_if %>
<% if $Title %><h5>$Title</h5><% end_if %>
$Content
</div>
</div>
<% end_if %>
<% end_loop %>
// ShortCode|
// Shortcode to render group of ItemBlocks(from CMS /available per page / Part of extra fields)
// into HTML
public static function ShortCodeItemBlocks($arguments, $content = null, $parser = null, $tagname) {
if (isset($arguments['classgroup'])) {
if (!$arguments['classgroup']){
return false;
}
$itemblock = Controller::curr();
$itemblock->ShortCodeClass = $arguments['classgroup'];
if (isset($arguments['size'])) {
$itemblock->Size = $arguments['size'];
}
if (isset($arguments['customclass'])) {
$itemblock->CC = $arguments['customclass'];
}
return $itemblock->renderWith(array('Shortcodes', 'ItemBlocks'));
} else {
$itemblock = Controller::curr();
if (isset($arguments['size'])) {
$itemblock->Size = $arguments['size'];
if (isset($arguments['customclass'])) {
$itemblock->CC = $arguments['customclass'];
}
}
return $itemblock->renderWith(array('Shortcodes', 'ItemBlocks'));
}
}
// USAGE IN CMS
[ItemBlocks, classgroup="something", size="3"]
[ItemBlocks, classgroup="other", size="3"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment