Moodle PHP Documentation 4.3
Moodle 4.3.5 (Build: 20240610) (7dcfaa79f78)
block_contents Class Reference

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.
 

Detailed Description

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.

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
Since
Moodle 2.0

Constructor & Destructor Documentation

◆ __construct()

block_contents::__construct ( array $attributes = null)

Create new instance of block content.

Parameters
array$attributes

Member Function Documentation

◆ add_class()

block_contents::add_class ( $class)

Add html class to block.

Parameters
string$class

◆ is_fake()

block_contents::is_fake ( )

Check if the block is a fake block.

Return values
boolean

Member Data Documentation

◆ $annotation

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.

'

◆ $arialabel

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.

◆ $attributes

array block_contents::$attributes

An array of attribute => value pairs that are put on the outer div of this block.

$id and $classes attributes should be set separately.

◆ $blockinstanceid

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.

◆ $blockpositionid

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.

◆ $collapsible

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.

◆ $controls

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.

◆ $skipid

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.

◆ $title

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

tags. Please do not cause invalid XHTML.


The documentation for this class was generated from the following file: