Moodle PHP Documentation 4.5
Moodle 4.5dev (Build: 20240606) (d3ae1391abe)
|
This class represents how a block appears on a page. More...
Public Member Functions | |
__construct (array $attributes=null) | |
Create new instance of block content. | |
add_class ($class) | |
Add html class to block. | |
is_fake () | |
Check if the block is a fake block. | |
Public Attributes | |
string | $annotation = '' |
Any small print that should appear under the block to explain to the teacher about the block, for example 'This is a sticky block that was added in the system context. | |
string | $arialabel = '' |
The label to use when the block does not, or will not have a visible title. | |
array | $attributes |
An array of attribute => value pairs that are put on the outer div of this block. | |
int | $blockinstanceid = 0 |
If this is the contents of a real block, this should be set to the block_instance.id. | |
int | $blockpositionid = 0 |
If this is a real block instance, and there is a corresponding block_position.id for the block on this page, this should be set to that id. | |
int | $collapsible = self::NOT_HIDEABLE |
One of the constants NOT_HIDEABLE, VISIBLE, HIDDEN. | |
string | $content = '' |
HTML for the content. | |
array | $controls = array() |
A (possibly empty) array of editing controls. | |
bool | $dockable = false |
Set this to true if the block is dockable. | |
array | $footer = '' |
An alternative to $content, it you want a list of things with optional icons. | |
int | $skipid |
All the blocks (or things that look like blocks) printed on a page are given a unique number that can be used to construct id="" attributes. | |
string | $title = '' |
The title of this block. | |
const | HIDDEN = 2 |
Used when the block has been collapsed. | |
const | NOT_HIDEABLE = 0 |
Used when the block cannot be collapsed. | |
const | VISIBLE = 1 |
Used when the block can be collapsed but currently is not. | |
Static Protected Attributes | |
static int | $idcounter = 1 |
Used to set $skipid. | |
This class represents how a block appears on a page.
During output, each block instance is asked to return a block_contents object, those are then passed to the $OUTPUT->block function for display.
contents should probably be generated using a moodle_block_..._renderer.
Other block-like things that need to appear on the page, for example the add new block UI, are also represented as block_contents objects.
block_contents::__construct | ( | array | $attributes = null | ) |
Create new instance of block content.
array | $attributes |
block_contents::add_class | ( | $class | ) |
Add html class to block.
string | $class |
block_contents::is_fake | ( | ) |
Check if the block is a fake block.
boolean |
string block_contents::$annotation = '' |
Any small print that should appear under the block to explain to the teacher about the block, for example 'This is a sticky block that was added in the system context.
'
string block_contents::$arialabel = '' |
The label to use when the block does not, or will not have a visible title.
You should never set this as well as title... it will just be ignored.
array block_contents::$attributes |
int block_contents::$blockinstanceid = 0 |
If this is the contents of a real block, this should be set to the block_instance.id.
Otherwise this should be set to 0.
int block_contents::$blockpositionid = 0 |
If this is a real block instance, and there is a corresponding block_position.id for the block on this page, this should be set to that id.
Otherwise it should be 0.
int block_contents::$collapsible = self::NOT_HIDEABLE |
One of the constants NOT_HIDEABLE, VISIBLE, HIDDEN.
Whether the user can toggle whether this block is visible.
array block_contents::$controls = array() |
A (possibly empty) array of editing controls.
Each element of this array should be an array('url' => $url, 'icon' => $icon, 'caption' => $caption). $icon is the icon name. Fed to $OUTPUT->image_url.
int block_contents::$skipid |
All the blocks (or things that look like blocks) printed on a page are given a unique number that can be used to construct id="" attributes.
This is set automatically be the prepare() method. Do not try to set it manually.
string block_contents::$title = '' |
The title of this block.
If this came from user input, it should already have had format_string() processing done on it. This will be output inside