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

Building a block with library image input?

I'm trying to build a block that has the ability to pull an image from the library (or, since I'm desperate, from anywhere, even a remote URL), but I can't figure it out, and I'm new to PHP... Does anyone have any pointers? I tried reading http://phple…

blocks

how can i add multiple images in a block. ie: 3 images in a horizontal row

Hardcode a custom render view

The client wants a blog block in the footer of every page. I got it to work by hard coding it no problem, but then I needed to use a custom view to meet their design needs, so I created a view.php and view.css in /blocks/rss_displayer/templates/bullet_dat…

Theoretical Question About Page Attributes

I just had this sudden realization that I can do so much more with C5 out of the box than I thought I could. Kinda funny how those little things just kinda "click" huh? Anyways...let's say that my homepage has a JavaScript rotator that slides through h…