This is the documentation for concrete5 version 5.6 and earlier. View Current Documentation

From time to time you may find yourself access a BlockType object. Here are the various methods available from that object.

Load a Block Type Object

$blockType = BlockType::getByID($id)

$blockType = BlockType::getByHandle($blockTypeHandle)

Returns a BlockType object given a passed block type ID or handle.

Methods

$blockType->isCoreBlockType()

Returns true if the block type ships with concrete5.

$blockType->getPackageID()

Returns the package ID of the block type, or zero if the block type ships with concrete5 or is custom.

$blockType->getPackageHandle()

Returns the package handle of the block type, or null if the block type ships with concrete5 or is custom.

$blockType->getCount()

Returns the number of unique instances of this block type.

$blockType->getBlockTypeDescription()

Returns the description of the block type.

$blockType->getBlockTypeCustomTemplates()

Returns an array of custom templates. Checks the core block type directory, the local overrides directory, and any packages to see if they specify custom templates for this block type.

BlockType::installBlockTypeFromPackage($btHandle, $pkg)

Installs a block type from a particular package. Useful in a package's install() method.

	public function install() 		$pkg = parent::install(); 		BlockType::installBlockTypeFromPackage('my_block_type', $pkg); 	}  

$blockType->refresh()

Refreshes the block type's database schema (stored in db.xml).

BlockType::installBlockType($btHandle)

Installs a local block type based on its handle.

$blockType->render($view)

Renders a particular view of a block type, using the public $controller variable as the block type's controller

$blockType = BlockType::getByHandle('content'); 	$blockType->controller->content = 'This is my content.'; 	$blockType->render('view');

$controller = $blockType->getController()

Returns the extended BlockController for the particular BlockType object.

$blockType->getBlockTypePath()

Returns a path to where the block type's files are located.

$blockType->inc($file, $args = array())

Extracts all items passed through $args, and then includes the file from either the local directory or the core directory.

$blockType->inc('header.php');

$blockType->delete()

Deletes the block type. Only removes the block type from the BlockTypes table, not any of the information in the other tables.

$blockType->getBlockTypeInterfaceWidth()

Returns the width that the block thinks it needs to be, when adding or editing.

$blockType-> getBlockTypeInterfaceHeight()

Returns the height that the block thinks it needs to be, when adding or editing.

Loading Conversation