Create child theme in Osclass

Child theme in osclass (as in wordpress, prestashop or other classifieds scripts) is tool that allow to modify theme without affecting original theme.

Uncategorized
30. Mar 2022
2693 views
Create child theme in Osclass

Child theme in osclass (as in wordpress, prestashop or other classifieds scripts) is tool that allow to modify theme without affecting original theme. Child theme allows to update original theme, without affecting your modifications. Objective of child theme is not to replace everything, but allow slightly modifications in particular files, it's good to note that child theme will contains only files those should be replaced or modified.

Create blank/empty child theme

We will need several files to create our blank child theme, for next of this article we will be using Gamma Osclass Theme and will try to create Gamma Child Osclass Theme.

  1. Create folder for our child theme in oc-content/themes in format yourtheme_child, so in our case it is gamma_child
  2. Into gamma_child copy index.php and screenshot.png
  3. Open index.php and add Parent Theme value and update name (so you see difference in oc-admin), referencing what is parent theme for our child, in our case it's gamma. Index.php will look like this:
    /*
    Theme Name: Gamma CHILD Osclass Theme
    Theme URI: https://osclasspoint.com/
    Description: Responsive fast and clean premium osclass theme
    Version: 1.0.0
    Author: MB Themes
    Author URI: https://osclasspoint.com
    Widgets: header,footer
    Theme update URI: gamma-osclass-theme
    Product Key: GFE1crrhnvi0AtRiagJp
    Parent Theme: gamma
    */
    ?>

Child theme is created and ready to use activate from oc-admin! Keep in mind you cannot remove parent theme when using child theme. This step is last in most of tutorials, but what you should do next? Noone knows that even osclass docs does not provide more details.... so let's continue!

 

Working with child theme

There are few things to remember when working with your child theme.

  • In PHP, each function must have unique name. If you want to update some function from parent theme, you can copy & paste it, but name of it must be changed and usage of function updated in child theme
  • There are 2 types of files replacement: 
    • Osclass initiated - for files directly loaded by by osclass as: main.php, search.php, item.php, user-register.php, ...
    • Theme initiated - files loaded from theme files as: header.php, head.php, loop-single.php, search_gallery.php, ...

Let's do something on example. Our objective is: 

  1. Create custom CSS stylesheet in child theme and add it into theme
  2. Replace theme footer on homepage with custom text: Hello footer!!!
  3. Update home page and add there text: Hello world!!!

Comments

No comments has been added on this post

Add new comment

You must be logged in to add new comment. Log in
Categories
Lately commented
Are you a professional seller? Create an account
Non-logged user
Hello wave
Welcome! Sign in or register
CONFIG
Backoffice Show Banners