0

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 pages,blocks and widgets. How we can create like this exactly from scratch? Please anyone suggest with links or with step by step Guide,

All i need is i am going to create two custom themes, so page,and blocks are different for each theme.

So whenever a,theme is applied in admin, those page content should show in frontend.. Thanks

3
  • 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, 2018 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. Aug 13, 2018 at 6:05

1 Answer 1

2

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();
    }
}
9
  • Can you please provide simple steps just to show only slider block for now? rest i will do it myself Jul 17, 2018 at 10:18
  • @jafar i added the example too. Jul 17, 2018 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? Jul 17, 2018 at 10:49
  • block identifier is unique test-block. you theme have you own identifier that are used in theme. Jul 17, 2018 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? Jul 17, 2018 at 11:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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