I want to display certain CMS pages on categories and products, which the administrator assigns to the category or product. They would appear as cards. Somehow first the title of the CMS page and then as a description let's say 100 initial characters from the content. How to get those first 100 characters from page content?
You can Try and add this on your phtml. Please do inject the CMS Page model.
$cms = \Magento\Framework\App\ObjectManager::getInstance()->get(\Magento\Cms\Model\Page::class); $page = $cms->load('home','identifier'); $pageTitle = $page->getTitle(); $pageContent = $page->getContent(); $pageContent = substr($pageContent, 0, 100); echo '<h3>' . $pageTitle . '</h3>'; echo '<p>' . $pageContent . '...</p>';