TemplatedBlock Class Reference
A block that renders itself from a template. More...
Public Member Functions |
|
| __construct ($name, $title, $template, $index=1000, $position=self::LEFT) | |
| Constructor. |
|
| get_content () | |
| Get content of block (HTML). |
|
| render ($policy=self::NONE) | |
| Renders what should be rendered. |
|
Protected Member Functions |
|
| configure_view ($view) | |
| Configure the view. |
|
| create_view ($template) | |
| Create and configure the view. |
|
Protected Attributes |
|
| $template = '' | |
| $view_is_rendered = false | |
Detailed Description
A block that renders itself from a template.
The block instance is available as $block within the template. So you may change title or name like this:
$block->set_title('New title'); $block->set_name('newname');
Definition at line 16 of file templated.block.cls.php.
Constructor & Destructor Documentation
| TemplatedBlock::__construct | ( | $ | name, | |
| $ | title, | |||
| $ | template, | |||
| $ | index = 1000, |
|||
| $ | position =
self::LEFT |
|||
| ) |
Constructor.
- Parameters:
-
string $name The name of this block. Used as class, too string $title The title of the block. Displayed as heading, e.g. string $template The template to render integer $index The block's index. A block with lowest index will be displayed first enum $position Where the block is to be displayed.
Reimplemented from BlockBase.
Definition at line 29 of file templated.block.cls.php.
Member Function Documentation
| TemplatedBlock::configure_view | ( | $ | view | ) | [protected] |
Configure the view.
- Parameters:
-
IView $view
Reimplemented in TemplatedParameterizedBlock.
Definition at line 52 of file templated.block.cls.php.
| TemplatedBlock::create_view | ( | $ | template | ) | [protected] |
Create and configure the view.
- Parameters:
-
string $template The template
- Returns:
- IView
Definition at line 40 of file templated.block.cls.php.
00040 { 00041 $view = ViewFactory::create_view(IViewFactory::MESSAGE, $template, $page_data); 00042 $view->assign('block', $this); 00043 $this->configure_view($view); 00044 return $view; 00045 }
| TemplatedBlock::get_content | ( | ) |
Get content of block (HTML).
- Returns:
- string
Reimplemented from BlockBase.
Definition at line 61 of file templated.block.cls.php.
00061 { 00062 if (!$this->view_is_rendered) { 00063 $this->view_is_rendered = true; 00064 $view = $this->create_view($this->template); 00065 $this->set_content($view->render()); 00066 } 00067 return parent::get_content(); 00068 }
| TemplatedBlock::render | ( | $ | policy =
self::NONE |
) |
Renders what should be rendered.
- Parameters:
-
int $policy Defines how to render, meaning depends on implementation
- Returns:
- string The rendered content
Reimplemented from BlockBase.
Definition at line 76 of file templated.block.cls.php.
00076 { 00077 if (!$this->view_is_rendered) { 00078 $this->get_content(); 00079 } 00080 return parent::render($policy); 00081 }
Member Data Documentation
TemplatedBlock::$template = ''
[protected] |
Definition at line 18 of file templated.block.cls.php.
TemplatedBlock::$view_is_rendered = false
[protected] |
Definition at line 17 of file templated.block.cls.php.
The documentation for this class was generated from the following file:
- contributions/page.blocks/controller/base/templated.block.cls.php
