Bilişim dünyasına kaliteli, özgün ve Türkçe içerikler kazandırmayı hedefleyen bir platform..

friends friends friends

Yii2 Framework Widget Oluşturma

C:\wamp\www\yii2\vendor\yiisoft\yii2\widgets klasöründe yeni bir HelloWidget.php dosyası açılır.

namespace yii\widgets;

use yii\base\Widget;
use yii\helpers\Html;

class HelloWidget extends Widget
{
    public $message;

    public function init()
    {
        parent::init();
        if ($this->message === null) {
            $this->message = 'Hello World';
        }
    }

    public function run()
    {
        return Html::encode($this->message);
    }
}

view.php dosyasında kullanımı ise

use yii\widgets\HelloWidget;

echo HelloWidget::widget(['message' => 'Good morning']) 

init() - should contain the widget properties,
run() - should contain rendering result of the widget
Yii2 Framework Widget
0 Beğeni
Yii2 Framework
Önceki Yazı

Yii2 Framework Breadcrumbs

11 Ekim 2020 tarihinde yayınlandı.
Sonraki Yazı

Yii2 Framework Keyword ve Description

11 Ekim 2020 tarihinde yayınlandı.
arrow