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.
Make sure to check our CSS customization guide with simple examples: https://docs.osclasspoint.com/customizations-of-theme-basic
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.
<?php
/*
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!
There are few things to remember when working with your child theme.
Let's do something on example. Our objective is:
Stylesheet is referenced from head.php, this file from header.php and header is called from each file, so creating custom head.php does not make sense. Rather then we will create function to add our stylesheet via hook from functions.php
function gam_child_custom_css() {
osc_enqueue_style('style-child', osc_current_web_theme_url('css/style-child.css'));
}
osc_add_hook('header', 'gam_child_custom_css')
<link href="https://dev3.abprofitrade.eu/oc-content/themes/gamma/css/style-child.css" rel="stylesheet" type="text/css" />
Now we will update footer.php to have custom footer on home page. Note if you would like to have custom footer in all the pages, you would repeat bellow procedure for every file in theme.
<?php osc_current_web_theme_path('footer.php'); ?>
<?php include osc_base_path() . 'oc-content/themes/gamma_child/footer.php'; ?>
<footer>Hello world footer!</footer>
Your footer is now updated.
We will now update home page and put there own text or block.
Your home page is now updated.
We have created custom child theme in classifieds, can now freely update our parent theme etc... however there some questions unanswered:
Basically we recommend to use child themes just for custom stylesheets, javascripts and functions to be added via hook, hence copying all the files from parent into child and updating it all the time there is new update in parent is making usage of child theme useless. Before using or bying your classifieds theme make sure it match your expectation and avoid redeveloping it from scratch, as it may be contra productive.