I have create module. i call it int cms page.
{{block class="Namespace/Module/Block/Custom" template="Namespace_Module::html/my.phtml" custom_id=1}}
how to get custom_id value? in Namespace/Module/Block/Custom
or in my.phtml?
In your .phtml file you need to use block :
Try below code :
$custom_id = $block->getData('custom_id');
echo $custom_id;
You need to use
$block->getData('custom_id')
$this inside a template refers to the instance of the PHP template engine used for rendering the block, not the block itself.
In .phtml
file
$custom_id = $this->getData("custom_id");
In your Block file
public function __construct(
\Magento\Catalog\Block\Product\Context $context,
array $data = []
) {
parent::__construct($context, $data);
}
$block->getData('custom_id');