2015-08-16 16:08:46 +00:00
# Themes
* [Home ](help )
To change the look of friendica you have to touch the themes.
2020-06-15 17:47:23 +00:00
The current default theme is [Vier ](https://github.com/friendica/friendica/tree/stable/view/theme/vier ) but there are numerous others.
2022-04-07 00:36:05 +00:00
Have a look at [github.com/bkil/friendica-themes ](https://github.com/bkil/friendica-themes ) for an overview of the existing themes.
2015-08-17 07:17:36 +00:00
In case none of them suits your needs, there are several ways to change a theme.
2015-08-18 08:02:33 +00:00
So, how to work on the UI of friendica.
You can either directly edit an existing theme.
2015-08-16 16:08:46 +00:00
But you might loose your changes when the theme is updated by the friendica team.
2015-08-17 07:17:36 +00:00
If you are almost happy with an existing theme, the easiest way to cover your needs is to create a new theme, inheritating most of the properties of the parent theme and change just minor stuff.
2015-08-18 08:02:33 +00:00
The below for a more detailed description of theme heritage.
2015-08-16 16:08:46 +00:00
Some themes also allow users to select *variants* of the theme.
Those theme variants most often contain an additional [CSS ](https://en.wikipedia.org/wiki/CSS ) file to override some styling of the default theme values.
2022-11-04 16:28:21 +00:00
From the themes in the main repository *vier* and *vier* are using this methods for variations.
2015-08-17 07:17:36 +00:00
Quattro is using a slightly different approach.
2015-08-16 16:08:46 +00:00
Third you can start your theme from scratch.
Which is the most complex way to change friendicas look.
But it leaves you the most freedom.
2015-08-17 07:17:36 +00:00
So below for a *detailed* description and the meaning of some special files.
2015-08-16 16:08:46 +00:00
2015-08-17 07:17:36 +00:00
### Styling
2015-08-16 16:08:46 +00:00
If you want to change the styling of a theme, have a look at the themes CSS file.
In most cases, you can found these in
2015-08-17 07:17:36 +00:00
/view/theme/**your-theme-name**/style.css
2015-08-16 16:08:46 +00:00
sometimes, there is also a file called style.php in the theme directory.
2023-03-22 03:16:46 +00:00
This is only needed if the theme allows the user to change certain things of the theme dynamically.
2015-08-16 16:08:46 +00:00
Say the font size or set a background image.
2015-08-17 07:17:36 +00:00
### Templates
2015-08-16 16:08:46 +00:00
If you want to change the structure of the theme, you need to change the templates used by the theme.
Friendica themes are using [SMARTY3 ](http://www.smarty.net/ ) for templating.
The default template can be found in
/view/templates
if you want to override any template within your theme create your version of the template in
2015-08-17 07:17:36 +00:00
/view/theme/**your-theme-name**/templates
2015-08-16 16:08:46 +00:00
any template that exists there will be used instead of the default one.
2015-08-17 07:17:36 +00:00
### Javascript
2015-08-16 16:08:46 +00:00
The same rule applies to the JavaScript files found in
/js
they will be overwritten by files in
2016-02-09 08:39:29 +00:00
/view/theme/**your-theme-name**/js.
2015-08-16 16:08:46 +00:00
## Creating a Theme from Scratch
Keep patient.
2017-05-19 20:37:45 +00:00
Basically what you have to do is identify which template you have to change so it looks more like what you want.
2015-08-16 16:08:46 +00:00
Adopt the CSS of the theme accordingly.
And iterate the process until you have the theme the way you want it.
2018-03-03 14:47:36 +00:00
*Use the source Luke.* and don't hesitate to ask in @[developers](https://forum.friendi.ca/profile/developers) or @[helpers](https://forum.friendi.ca/profile/helpers).
2015-08-17 07:17:36 +00:00
2015-08-16 16:08:46 +00:00
## Special Files
### unsupported
2015-08-18 08:02:33 +00:00
If a file with this name (which might be empty) exists in the theme directory, the theme is marked as *unsupported* .
2015-08-16 16:08:46 +00:00
An unsupported theme may not be selected by a user in the settings.
Users who are already using it wont notice anything.
### README(.md)
The contents of this file, with or without the .md which indicates [Markdown ](https://daringfireball.net/projects/markdown/ ) syntax, will be displayed at most repository hosting services and in the theme page within the admin panel of friendica.
This file should contain information you want to let others know about your theme.
### screenshot.[png|jpg]
If you want to have a preview image of your theme displayed in the settings you should take a screenshot and save it with this name.
Supported formats are PNG and JPEG.
### theme.php
This is the main definition file of the theme.
2018-01-25 14:00:23 +00:00
In the header of that file, some meta information is stored.
2022-11-04 16:28:21 +00:00
For example, have a look at the theme.php of the *vier* theme:
2015-08-16 16:08:46 +00:00
< ?php
/**
2022-11-04 16:28:21 +00:00
* [Licence]
*
* Name: Vier
* Version: 1.2
2015-08-16 16:08:46 +00:00
* Author: Fabio < http: // kirgroup . com / profile / fabrixxm >
2022-11-04 16:28:21 +00:00
* Author: Ike < http: // pirati . ca / profile / heluecht >
* Author: Beanow < https: // fc . oscp . info / profile / beanow >
* Maintainer: Ike < http: // pirati . ca / profile / heluecht >
* Description: "Vier" is a very compact and modern theme. It uses the font awesome font library: http://fortawesome.github.com/Font-Awesome/
2015-08-16 16:08:46 +00:00
*/
2018-01-25 14:00:23 +00:00
You see the definition of the theme's name, it's version and the initial author of the theme.
2017-05-19 20:37:45 +00:00
These three pieces of information should be listed.
If the original author is no longer working on the theme, but a maintainer has taken over, the maintainer should be listed as well.
2018-01-25 14:00:23 +00:00
The information from the theme header will be displayed in the admin panel.
2015-08-16 16:08:46 +00:00
2018-05-07 16:28:55 +00:00
The first thing in file is to import the `App` class from `\Friendica\` namespace.
use Friendica\App;
This will make our job a little easier, as we don't have to specify the full name every time we need to use the `App` class.
2017-05-19 20:37:45 +00:00
The next crucial part of the theme.php file is a definition of an init function.
2015-08-16 16:08:46 +00:00
The name of the function is < theme-name > _init.
2022-11-04 16:28:21 +00:00
So in the case of vier it is
2015-08-16 16:08:46 +00:00
2022-11-04 16:28:21 +00:00
function vier_init(App $a) {
$a->theme_info = array();
$a->set_template_engine('smarty3');
2015-08-16 16:08:46 +00:00
}
2017-05-19 20:37:45 +00:00
Here we have set the basic theme information, in this case they are empty.
2015-08-16 16:08:46 +00:00
But the array needs to be set.
And we have set the template engine that should be used by friendica for this theme.
At the moment you should use the *smarty3* engine.
There once was a friendica specific templating engine as well but that is not used anymore.
If you like to use another templating engine, please implement it.
If you want to add something to the HTML header of the theme, one way to do so is by adding it to the theme.php file.
To do so, add something alike
2019-12-30 22:35:01 +00:00
DI::page()['htmlhead'] .= < < < EOT
2015-08-16 16:08:46 +00:00
/* stuff you want to add to the header */
EOT;
So you can access the properties of this friendica session from the theme.php file as well.
### default.php
This file covers the structure of the underlying HTML layout.
The default file is in
/view/default.php
2015-08-16 16:18:01 +00:00
if you want to change it, say adding a 4th column for banners of your favourite FLOSS projects, place a new default.php file in your theme directory.
2017-05-19 20:37:45 +00:00
As with the theme.php file, you can use the properties of the $a variable with holds the friendica application to decide what content is displayed.