I am trying to create custom theme with inbuilt Cms pages and Blocks? For example once the theme files moved and installed can able to see all the blocks and pages are created in magento.

I followed below link https://www.cloudways.com/blog/create-custom-theme-magento-2-part-1/

Which is for overriding luma theme but not able to Preview the theme with content.

How can we create theme with full package along with slider, Blocks and widgets like the Paid themes? For example in this Url: https://www.hiddentechies.com/bizkick-responsive-theme-magento-2.html

Once we buy we will get full package with all css and js files. How we can create like this exactly from scratch? Please anyone suggest with links or with step by step Guide?

  • You need to create the sliders/blocks yourself, you can use sample data included here but it doesn't contain sliders. – Ben Crook Jul 17 at 9:52
  • Yes, Like this i already created new theme, i am looking for how to create themes like the paid one, There we will get all blocks and pages all installed once the theme is applied, but the above link you provided that creates the theme, for that we need to add static blocks for that theme mannually. – jafar pinjar Aug 13 at 6:05

This is too broad question but i tried sum up for you. You can create the basic theme with currently provided link. But for creating theme data import you need to create module's for importing data. Like if follow this example for creating the cms block for run time.

Create installer Script

Create csv data

Save with model

Now taking example

<?php

namespace QaisarSatti\HelloWorld\Setup;

use Magento\Framework\Setup\InstallSchemaInterface;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\SchemaSetupInterface;
use Magento\Framework\DB\Ddl\Table;

class InstallSchema implements InstallSchemaInterface {
    private $blockFactory;

    public function __construct(
\Magento\Cms\Model\BlockFactory $blockFactory
 )
    {

    $this->blockFactory = $blockFactory;
    }  
    public function install( SchemaSetupInterface $setup, ModuleContextInterface $context ) {
        $installer = $setup;

        $installer->startSetup();

       $testBlock = [
         'title' => 'Test block title',
         'identifier' => 'test-block',
         'stores' => [0],
         'is_active' => 1,
         ];
        $this->blockFactory->create()->setData($testBlock)->save();

        $installer->endSetup();
    }
}
  • Can you please provide simple steps just to show only slider block for now? rest i will do it myself – jafar pinjar Jul 17 at 10:18
  • @jafar i added the example too. – Qaisar Satti Jul 17 at 10:29
  • Thanks for posting it. How it is relate to custom theme? say for example My custom theme is <Demo>/<CustomDemo>. with same name do i need to create custom module with this?. Can you please elaborate it with some steps? – jafar pinjar Jul 17 at 10:49
  • block identifier is unique test-block. you theme have you own identifier that are used in theme. – Qaisar Satti Jul 17 at 10:53
  • Please explain it from scratch? yes that is unique id, but my question is different, How can i start building theme can you please explain with directory structure and files? – jafar pinjar Jul 17 at 11:32

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.