PHP Класс WPDKView
## Overview
To create a view use
$view = new WPDKView( 'my-view' );
$view->content = 'Hello World";
$view->display();
Or
$view = WPDKView::initWithContent( 'my-view', '', 'Hello World' );
$view->display();
Or, suggested method
class MyView extends WPDKView {
public function __construct() {
parent::__construct( 'my-id', 'additional class' );
}
Override
public function draw() {
echo 'Hello World';
}
}
### draw() VS content
If you like use a
WPDKView directly, you will use the
content property. Otherwise, you can sub class the
WPDKView
and then use the method
draw() to diplay the content of the view.
### Observing
You can observe some event via filters and actions. For example you can catch when a content has been drawed.
For fo this you can use the filter
wpdk_view_did_draw_content:
add_action( 'wpdk_view_did_draw_content', array( $this, 'wpdk_view_did_draw_content') );
public function wpdk_view_did_draw_content( $view ) {
if ( is_a( $view, 'WPDKHeaderView' ) ) {
Do something
}
}
In this case we had used the "is_a" function to understand which type of view was passed. Alternatively you can check
the view id, for example.
public function wpdk_view_did_draw_content( $view ) {
if ( 'my_id' == $view->id ) {
Do something
}
}
Показать файл
Открыть проект
Примеры использования класса
Открытые свойства
Открытые методы
Описание методов
__construct()
публичный Метод
Create an instance of WPDKView class
addSubview()
публичный Метод
Add a view in queue views
public addSubview ( WPDKView $view ) : WPDKView |
$view |
WPDKView |
|
Результат |
WPDKView |
|
display()
публичный Метод
Display the HTML markup content for this view.
Return the HTML markup content of this view
initWithContent()
публичный статический Метод
Create an instance of WPDKView class with a content
initWithFrame()
публичный статический Метод
removeFromSuperview()
публичный Метод
Remove this view from its superview
Описание свойств
$__version публичное свойство
public string $__version |
Результат |
string |
|
$class публичное свойство
The CSS class or list of classes
public array $class |
Результат |
array |
|
$content публичное свойство
The HTML markup content of this view
public string $content |
Результат |
string |
|
Key value pairs array Attribute data: data-attribute = value
public array $data |
Результат |
array |
|
The unique id for this view
public string $id |
Результат |
string |
|
$style публичное свойство
public array $style |
Результат |
array |
|
$subviews публичное свойство
An array list with the subviews of this view
public array $subviews |
Результат |
array |
|
$superview публичное свойство
public WPDKView $superview |
Результат |
WPDKView |
|