Difference between revisions of "Hubzilla:Extending a Theme"

From Federated Fandom Wiki
Jump to navigation Jump to search
(First steps)
 
(→‎Setting up your theme: removed bracket version of code for clarity)
Line 9: Line 9:
 
First, create a folder with your theme's name (all the existing themes have lowercase names, but I'm not sure if that is a requirement or not). You'll need to create a php folder inside this folder, and a new php file named <code>theme.php</code>. You will want this file to look something like this:
 
First, create a folder with your theme's name (all the existing themes have lowercase names, but I'm not sure if that is a requirement or not). You'll need to create a php folder inside this folder, and a new php file named <code>theme.php</code>. You will want this file to look something like this:
  
<syntaxhighlight lang="PHP">
+
<syntaxhighlight lang="php">
<?php
+
<?php  
  
 
/**
 
/**
Line 25: Line 25:
 
     App::$theme_info['extends'] = 'redbasic';
 
     App::$theme_info['extends'] = 'redbasic';
 
}
 
}
 +
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
  
 
Replace the name, description, and author fields with your own info, and rename the function so it's <code>[your project folder name]_init</code>.
 
Replace the name, description, and author fields with your own info, and rename the function so it's <code>[your project folder name]_init</code>.

Revision as of 05:25, 4 January 2019

Most themes so far are derived from the 'redbasic' theme - they take its basic properties and skin it, basically. The redbasic theme is defined in the core repository, under view/theme/redbasic, so you can get a feel for what it contains there.

Getting Started

  • You will need to be a little bit familiar with git. See the Git Primer for more details.
  • You should also be a little familiar with php. You do not need to be a programmer, but just be able to avoid running screaming into the night at the sight of a few lines of code.
  • You probably will want an installed copy of Hubzilla to test your theme on.

Setting up your theme

First, create a folder with your theme's name (all the existing themes have lowercase names, but I'm not sure if that is a requirement or not). You'll need to create a php folder inside this folder, and a new php file named theme.php. You will want this file to look something like this:

<?php 

/**
 *   * Name: Demitas Test
 *   * Description: A test theme so I can make sure I'm not giving crap instructions. :)
 *   * Version: 1.0
 *   * MinVersion: 2.3.1
 *   * MaxVersion: 4.0
 *   * Author: demitas
 *   * Compat: Hubzilla [*]
 */

function demitas_test_init(&$a) {
    App::$theme_info['extends'] = 'redbasic';
}


Replace the name, description, and author fields with your own info, and rename the function so it's [your project folder name]_init.

You might also want to change these if you know they are different:

  • Version: The version your theme is at - probably 1.0 at this point
  • MinVersion: This is the minimum version of Hubzilla that your theme will be compatible with
  • MaxVersion: This is the maximum version of Hubzilla that your theme will be compatible with.

To be continued...