diff --git a/doc/en/toc.html b/doc/en/toc.html index e9ef86fbc..84a5e88f9 100644 --- a/doc/en/toc.html +++ b/doc/en/toc.html @@ -79,6 +79,7 @@
diff --git a/doc/en/tutorials/DerivedTheme1.md b/doc/en/tutorials/DerivedTheme1.md deleted file mode 100644 index 3858a335f..000000000 --- a/doc/en/tutorials/DerivedTheme1.md +++ /dev/null @@ -1,96 +0,0 @@ -### Creating a Derived Theme - -**Lesson 1** - -A derived theme takes most of the settings from its "parent" theme and lets you change a few things to your liking without creating an entire theme package. - - -To create a derived theme, first choose a name. For our example we'll call our theme 'mytheme'. Hopefully you'll be a bit more creative. But throughout this document, wherever you see 'mytheme', replace that with the name you chose. - -**Directory Structure** - -First you need to create a theme directory structure. We'll keep it simple. We need a php directory and a css directory. Here are the Unix/Linux commands to do this. Assume that 'mywebsite' is your top level hubzilla folder. - - - cd mywebsite - mkdir view/theme/mytheme - mkdir view/theme/mytheme/css - mkdir view/theme/mytheme/php - - -Great. Now we need a couple of files. The first one is your theme info file, which describes the theme. - -It will be called view/theme/mytheme/php/theme.php (clever name huh?) - -Inside it, put the following information - edit as needed - - Display Settings as their default theme. - -**Lesson 2** - -If you want to use the redbasic schemas for your derived theme, you have to do a bit more. - -Do everything as above, but don't create view/theme/mytheme/php/style.php, but copy instead view/theme/redbasic/php/style.php to view/theme/mytheme/php/style.php. Modify that file and remove (or comment out) these two lines: - - if(local_channel() && App::$channel && App::$channel['channel_theme'] != 'redbasic') - set_pconfig(local_channel(), 'redbasic', 'schema', '---'); - -Also add this line at the bottom: - - echo @file_get_contents('view/theme/mytheme/css/style.css'); - -To show the schema selector you have to copy view/theme/redbasic/tpl/theme_settings.tpl to view/theme/mytheme/tpl/theme_settings.tpl. Modify that file and replace the lines: - - {{if $theme == redbasic}} - {{include file="field_select.tpl" field=$schema}} - {{/if}} - -with: - - {{include file="field_select.tpl" field=$schema}} diff --git a/doc/en/tutorials/derived_theme.md b/doc/en/tutorials/derived_theme.md new file mode 100644 index 000000000..00d43e535 --- /dev/null +++ b/doc/en/tutorials/derived_theme.md @@ -0,0 +1,89 @@ +## Creating a Derived Theme + +### Lesson 1 – Getting started + +A derived theme takes most of the settings from its "parent" theme and lets you change a few things to your liking without creating an entire theme package. + + +To create a derived theme, first choose a name. For our example we'll call our theme 'mytheme'. Hopefully you'll be a bit more creative. But throughout this document, wherever you see 'mytheme', replace that with the name you chose. + +#### Directory Structure + +First you need to create a theme directory structure. We'll keep it simple. We need a php directory and a css directory. Here are the Unix/Linux commands to do this. Assume that 'mywebsite' is your top level hubzilla folder. + + +``` +$ cd mywebsite +$ mkdir view/theme/mytheme +$ mkdir view/theme/mytheme/css +$ mkdir view/theme/mytheme/php +``` + +#### The Theme Info file + +Great. Now we need a couple of files. The first one is your theme info file, which describes the theme. + +It will be called `view/theme/mytheme/php/theme.php` (clever name huh?) + +Inside it, put the following information - edit as needed + +```php + + * Extends: redbasic + */ +``` + +Remember to rename the `mytheme_init` function with your theme name. In this case we will be extending the theme 'redbasic'. + +#### The PCSS file and style.css + +Now create another file. We call this a PCSS file, but it's really a PHP file. + +The file is called `view/theme/mytheme/php/style.php`. + +In it, put the following: + +```php +Display Settings as their default theme. + +#### Theme configuration and schemas + +If you want to keep the various configuration options for the derived theme, you have to add a configuration class for your child theme. + +Add another file, this time in `view/theme/mytheme/php/config.php`. Add the following content to it: + +```php + false, 'unsupported' => false, 'theme_color' => '', - 'background_color' => '' + 'background_color' => '', + 'extends' => '', ); if(file_exists("view/theme/$theme/experimental")) @@ -1077,10 +1078,11 @@ function theme_include($file, $root = '') { $root = $root . '/'; $theme_info = App::$theme_info; - if(array_key_exists('extends',$theme_info)) - $parent = $theme_info['extends']; - else + if(empty($theme_info['extends'])) { $parent = 'NOPATH'; + } else { + $parent = $theme_info['extends']; + } $theme = Zotlabs\Render\Theme::current(); $thname = $theme[0];