mirror of
https://github.com/monstra-cms/monstra.git
synced 2025-08-02 19:27:52 +02:00
Blocks Plugin: added ability create and render inline content blocks with {block_inline} and {block_inline_create}
This commit is contained in:
@@ -36,12 +36,52 @@
|
|||||||
// Add shortcode {block get="blockname"}
|
// Add shortcode {block get="blockname"}
|
||||||
Shortcode::add('block', 'Block::_content');
|
Shortcode::add('block', 'Block::_content');
|
||||||
|
|
||||||
|
// Add shortcode {block_inline name="blockname"}
|
||||||
|
Shortcode::add('block_inline', 'Block::_inlineBlock');
|
||||||
|
|
||||||
|
// Add shortcode {block_inline_create name="blockname"} Block content here {/block_inline_create}
|
||||||
|
Shortcode::add('block_inline_create', 'Block::_createInlineBlock');
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Block Class
|
* Block Class
|
||||||
*/
|
*/
|
||||||
class Block {
|
class Block {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Inline Blocks
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public static $inline_blocks = array();
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create Inline Block
|
||||||
|
*/
|
||||||
|
public static function _createInlineBlock($attributes, $content) {
|
||||||
|
if (isset($attributes['name'])) {
|
||||||
|
Block::$inline_blocks[Security::safeName($attributes['name'], '_', true)] = array(
|
||||||
|
'content' => (string)$content,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Draw Inline Block
|
||||||
|
*/
|
||||||
|
public static function _inlineBlock($attributes) {
|
||||||
|
if (isset($attributes['name']) && isset(Block::$inline_blocks[$attributes['name']])) {
|
||||||
|
$content = Filter::apply('content', Text::toHtml(Block::$inline_blocks[$attributes['name']]['content']));
|
||||||
|
return $content;
|
||||||
|
} else {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get block
|
* Get block
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user