Creating a Magento Widget
Since widgets are created in the admin panel, we first need to write some Magento logic for the backend part of the widget.
Create the Widget Block
<?php declare(strict_types=1);
namespace ScandiTutorials\\CustomWidget\\Block\\Widget;
use Magento\\Framework\\View\\Element\\Template;
use Magento\\Widget\\Block\\BlockInterface;
class NewsletterWidget extends Template implements BlockInterface
{
protected $_template = "widget/newsletter_widget.phtml";
}<?php
/** ScandiTutorials\\CustomWidget\\Block\\Widget\\NewsletterWidget $block */
?>
<widget type="newsletter" data-title="<?= $block->escapeHtml($block->getData('title')) ?>"></widget>Last updated