How Tos – Create a custom theme in Bagisto

Creating a custom theme for Bagisto had been a hot topic lately. More and more users are actively trying our framework and we’re genuinely overwhelmed by it.

Coming on how to create a custom theme for Bagisto. It’s super easy!!!. With just a few lines of configuration code. Similarly following the traditional way of creating view files in Laravel would be enough.

Create a custom theme in Bagisto

Please follow the below steps on how to create a custom theme in Bagisto.

themes.php file inside the config directory of Bagisto’s root.

Contents of themes.php file having information of currently active theme named default.

Let’s go through the parameters of this theme’s file. Because the understanding of those parameters will help you in creating a custom theme.

An explanation for these parameters:

  1. default: Declared at the top signifies the currently active or default theme in Bagisto. It is assigned with the value ‘default’. The (string)default indicates the name of the currently active theme.

    Default parameter showing your currently active theme.

     

  2. themes: This parameter is where you’ve to define all essentials for your own custom theme. Multiple themes can also be created and used at the same time in Bagisto.
  3. Inside ‘themes’ there is another array by name ‘default‘ which is your currently active theme. Containing some key-value pairs.
    1. default‘: When you look inside this array name ‘default‘ it holds few more key-value pairs. such as ‘view_path‘, ‘assets_path‘, ‘name’ all those are explained below:

      Bagisto’s default theme parameters.

      1. views_path: It’ll take the path of your views or blade files that you wanna put up in your custom theme.
      2. assets_path: Responsible for your assets i.e images, CSS and javascript files, etc.
      3. name: Defines a global name for your theme inside Bagisto.
      4. parent: This is a magic parameter that you can find in the commented code below the sub array ‘default‘. Using this parameter you can make use of existing themes inside Bagisto and just customise them even further. This parameter will take the value of the ‘name’ parameter listed in point 3rd above.

        parent parameter allows you to use previously existing theme files.

         

Finally, define your own paths and name of your custom theme inside ‘themes.php’ file. And start creating view files. Do not forget to cover all get routes of shop package having a parameter called ‘view’.

All storefront routes are inside this file.

Make sure the name of the blade file should be same as passed in this GET route file like this:

For all views check all GET routes as they hold a view parameter with the value of view to be used.

We will consistently update this blog post, so don’t forget to keep a check on it regularly.

. . .

Comment

Add Your Comment

Be the first to comment.

css.php