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.

Guides
3. Jun 2021
908 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!!!
n semper, ligula sit amet hendrerit vehicula, ante ex porttitor elit, sit amet finibus lacus sem sit amet sem. Integer blandit volutpat ligula, ut imperdiet tortor pulvinar vel. Sed volutpat posuere euismod. Proin a risus sit amet tortor venenatis congue eu et sem. Aliquam dapibus aliquet ante, vitae porttitor nunc sodales non.
PHP, Osclass, Java, Python
Categories
Guides
Suspendisse tincidunt est at leo feugiat, eget dapibus orci rutrum. Fusce eu gravida augue, ac aliquet ante.
News
Nullam mollis risus id facilisis tincidunt. Sed tempor viverra dui, ac tristique sapien congue sed.
Tips and Tricks
Vivamus mattis maximus magna eget luctus. Donec purus leo, dictum in feugiat ac, dapibus a tellus. Nulla finibus dui et luctus ornare.
Lately commented
Go to OC-Admin Show Banners