I'm trying to create a custom block in the theme I created for Magento 2.1.8.
When I add the element to the default.xml
layout, I got the following exception:
Exception #0 (Magento\Framework\Exception\LocalizedException): Invalid block type: frontend\Custom\Simple\Block\Services
Exception #1 (ReflectionException): Class frontend\Custom\Simple\Block\Services does not exist
In the Custom/Simple/Block/Services.php
I have the following code:
<?php
namespace Custom\Simple\Block;
use Magento\Framework\View\Element\Template;
/**
* Services block
*/
class Services extends Template {
public function getTitle() {
return "Services";
}
}
In the default.xml
I've added this code:
<referenceContainer name="content">
<block class="frontend\Custom\Simple\Block\Services" name="services.test" template="Custom_simple::test.phtml">
<arguments>
<argument name="something" xsi:type="string">Value</argument>
</arguments>
</block>
</referenceContainer>
I've tried to change the class to: Custom\Simple\Block\Services
and I got the same error.
Thanks for your help!
Edit:
In the registration.php
I have the following code:
<?php
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::THEME,
'frontend/Customdac/Simple',
__DIR__
);