(1) first create a new module with a custom eav for your product content (this is just the InstallData.php
content):
<?php namespace <vendor>\<module_name>\Setup;
use Magento\Eav\Setup\EavSetup;
use Magento\Eav\Setup\EavSetupFactory;
use Magento\Framework\Setup\InstallDataInterface;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;
/**
* @codeCoverageIgnore
*/
class InstallData implements InstallDataInterface
{
/**
* EAV setup factory
*
* @var EavSetupFactory
*/
private $eavSetupFactory;
/**
* Init
*
* @param EavSetupFactory $eavSetupFactory
*/
public function __construct(EavSetupFactory $eavSetupFactory)
{
$this->eavSetupFactory = $eavSetupFactory;
/* assign object to class global variable for use in other class methods */
}
/**
* {@inheritdoc}
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
{
$setup->startSetup();
/** @var EavSetup $eavSetup */
$eavSetup = $this->eavSetupFactory->create(['setup' => $setup]);
/**
* Add attributes to the eav/attribute
*/
$eavSetup->addAttribute(
\Magento\Catalog\Model\Product::ENTITY,
'my_attribute',
[
'type' => 'text',
'backend' => '',
'frontend' => '',
'label' => 'my custom content',
'input' => 'textarea',
'class' => '',
'source' => '',
'global' => 1,
'visible' => true,
'required' => false,
'user_defined' => true,
'default' => 0,
'searchable' => false,
'filterable' => false,
'comparable' => false,
'visible_on_front' => false,
'used_in_product_listing' => true,
'wysiwyg_enabled' => true, // if you want a wysiwyg editor
'unique' => false,
'apply_to' => 'simple,configurable,virtual,bundle,downloadable,grouped',
'group' => 'General'
]
);
$setup->endSetup();
}
}
(2) in the module extend catalog_product_view.xml
to insert your attribute:
[I added mine as a new product tab]
<referenceBlock name="product.info.details">
<block class="Magento\Catalog\Block\Product\View\Description" name="{SOME_NAME}" template="product/view/attribute.phtml" group="detailed_info">
<arguments>
<argument name="at_call" xsi:type="string">getMyAttribute</argument>
<argument name="at_code" xsi:type="string">my_attribute</argument>
<argument name="css_class" xsi:type="string">{some class if you like}</argument>
<argument name="at_label" xsi:type="string">none</argument>
<argument name="title" translate="true" xsi:type="string">My tab label</argument>
</arguments>
</block>
</referenceBlock>
(3) now you can go to your magento admin and insert custom content (even html) into the attribute content like for every other attribute
You can use Magento\Framework\View\Element\Template
basic template.
Try this:
<div id="something">
{{block class="Magento\Framework\View\Element\Template" name="test" template="path/to/my/file.phtml" }}
</div>
This should work.
UPDATE:
If you need to display product information you have to use blocks from prduct view. Example:
<div id="something">
{{block class="Magento\Catalog\Block\Product\View\Description" name="test" template="path/to/my/file.phtml" }}
</div>
PHTML file position depends on your architecture. If you are not embedding this in a module you could put it in your template.
Example:
<div id="something">
{{block class="Magento\Catalog\Block\Product\View\Description" name="test" template="Magento_Theme::mytemplate.phtml" }}
</div>
And put your file under: design/frontend/yourtheme/default/Magento_Theme/mytemplate.phtml
Best Answer
If you want to display the static block on all cms pages with 2-columns-layout:
create a new file in your theme:
and add your static-block to the sidebar.
Keep in mind that the CMS-page needs to be set to 2-columns.
EDIT: REMOVED IN VERSION 2.3.4 but still possible in prior versions - If you want to display your static block on a specific cms page:
Navigate to to your CMS-Page:
go to "Design"
add following code to "Layout Update XML"
Take a look at the new documentation at https://devdocs.magento.com/guides/v2.3/frontend-dev-guide/layouts/xml-manage.html#create-cms-pageproductcategory-specific-layouts for Magento versions 2.3.4 or above as mentioned by @Luis Paulo Lohmann