This is my code:
app/code/Vendor/Module/view/frontend/templates/storecategories.phtml
<div> <h3> <a href=""> <?php $categoryId = 65; $_objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $category = $_objectManager->create('Magento\Catalog\Model\Category') ->load($categoryId); $childrenCategories = $category->getChildrenCategories(); echo $category->getName(); ?> </a> </h3> <ul> <?php foreach($childrenCategories as $childrenCategory) { echo "<li>" . "<a href=" . $childrenCategory->getUrl() . ">" . $childrenCategory->getName() . "</a>" . "</li>";} ?> </ul> For now it echo out categories and children categories.
What I want to achieve is to type block code
{{block class="Vendor\Module\Block\BlockName" category_id="49" template="Vendor_Module::storecategories.phtml"}} into admin panel/Content/Pages/Home page/Content text area and call for categories and subcategories without using echo.
I suppose that I need to create Block file, but have no clue what code in it should look like.
Maybe I need controller as well and some changes in storecategories.phtml too?