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.

Recent Discussions on this Topic

Copy from how-to, missing download link

This page http://www.concrete5.org/documentation/developers/blocks/creating-a-new-block-type/ is a copy of a how-to http://www.concrete5.org/documentation/how-tos/understanding-and-building-blocks-in-concrete5/ The link to the basic block file is broke…

Block Javascript corrupted Admin Edit ability

I inserted a HTML block with references to a script. I think the new script is preventing me from being able to edit that page. The top row of icons no longer displays in the brower. To fix this, can I just go into the database and delete the frows f…

Block sizing

Guys, I have inserted an image block, selected a 780 x 200 image and inserted. The block then displays at about 20px high. I have gone into edit mode 'edit' and 'design' but nothing seems to fix this. I am sure it simple but it beats me! Any suggestions p…

Block sizing

Guys, I have inserted an image block, selected a 780 x 200 image and inserted. The block then displays at about 20px high. I have gone into edit mode 'edit' and 'design' but nothing seems to fix this. I am sure it simple but it beats me! Any suggestions p…

Auto-including guestbook block in template?

Hello, I'm working on a custom template for my site, and I would like to auto-include a guestbook on each page. So, in my template where I want to include it, I've tried using the following code: And this displays a guest book, and it mostly wor…