Skip to content

Instantly share code, notes, and snippets.

@jgornick
Created February 11, 2014 03:55
Show Gist options
  • Save jgornick/8929009 to your computer and use it in GitHub Desktop.
Save jgornick/8929009 to your computer and use it in GitHub Desktop.
Concrete5: Add block to page type
<?php defined('C5_EXECUTE') or die('Access Denied.'); ?>
<?php $page = Page::getCurrentPage(); ?>
<?php $this->inc('elements/header.php'); ?>
<div class="container main">
<a href="/portfolio" title="Back to Portfolio">&lt; Back to Portfolio</a>
<h1><?php echo $page->getCollectionName(); ?></h1>
<?php
$area = new Area('portfolio');
$area->setBlockLimit(1);
$area->display($c);
$areaBlocks = $area->getAreaBlocksArray($c);
if (!$areaBlocks) {
$fileSet = FileSet::getByName($page->getCollectionName());
if ($fileSet != null) {
$fsId = intval($fileSet->getFileSetID());
$fileIds = array_map(
function($file) {
return intval($file->getFileID());
},
$fileSet->getFiles()
);
$galleryBlock = BlockType::getByHandle('sortable_fancybox_gallery');
$page->addBlock($galleryBlock, 'portfolio', array(
'fsID' => $fsId,
'displayColumns' => 3,
'sortedFileIDs' => implode(',', $fileIds),
'enableLightbox' => '1',
'thumbWidth' => '150',
'thumbHeight' => '150',
'fullWidth' => '800',
'fullHeight' => '600',
'displayColumns' => '3',
'lightboxTransitionEffect' => 'elastic',
'lightboxTitlePosition' => 'inside'
));
}
}
?>
</div>
<?php $this->inc('elements/footer.php'); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment