[Markdown] 

Templates: Home

Neuhub, Hubzilla, and Streams Templates

This wiki covers the many templates used in Hubzilla and Streams. Templates are an integral part of themes, and are used to change the appearance of pages and elements on pages. They contain the HTML use to build different parts of a page. Because Hubzilla and Streams both use the Smarty template system , you don't have to edit the PHP code in most cases.

There are the core templates, theme templates, and templates for widgets, addons, and modules. They are located in different locations.

This wiki discusses what each template does, and then refers you to various repositories for the actual code.

Lists of Template Files

Our list of templates are located here. This also contain some notes on how Neuhub uses these templates in its themes.

Location of Template Files & Order of Use

It looks for templates in multiple locations, and picks the version in the first location it finds it in. This allows you to override the template used by a widget, module, addon, or core.

Typically, you would place your own version of a template in your theme (or child theme), and it would override all other versions. Just give it the same file name as the original template file.

You can view the actual template files in the repositories, linked below.

№ 1. Theme Templates

It looks for a template in the active theme first.

It should be noted that the Hubzilla version of Redbasic and the Streams version of Redbasic are not the same, despite having the same name. Also, more links will be added here as more themes are released.

№ 2. Parent Theme

If you are using a child theme (also known as a derived theme), it will check to see if there is a version of the template in the parent theme next.

In theory, if you are using a theme derived from Redbasic, it will check Redbasic child theme first, the Redbasic, then the core. But I have been unable to duplicate this with other parent and child themes.

№ 3. Widget, Module, and Addon Templates

It checks to see if a template is available as part of a widget, module, or addon next.

Notes:

  • Templates for addons are usually included with the addon and placed in the addon/example/view/tpl subdirectory (if the name of the addon is "example").
  • Templates for widgets are often placed in a theme, however the tpl file can be placed in any directory that does not conflict with something else, such as the /custom folder.
  • Modules are usually distributed in addons, however you can create your own modules without being wrapped in an addon. This is usually done with site specific modules, and the templates are usually placed in the theme's tpl folder. But technically, the template could be anywhere, even the /custom folder.

№ 4. Core Templates

If it cannot find a template in the theme, widget, module, or addon, it tries the core.


Working with Templates

Which template is used?

The system is set up so that you can override what is inside an existing template without changing an existing template. It does this by looking for templates in multiple locations, and picking which one to use. It uses the first version it finds.

  1. Generally, it looks to see if your theme has a certain template available.
  2. If you are using a child theme, it checks to see if that template is available in the parent theme.
  3. If that is not available, it looks to see if your widget, module, or addon has a template available.
  4. And if it can't find a template in either of those places, it looks to see if the core code has a template to use.
  5. If it can't find one in any of those places, it gives an error.

Finding Variables in a Theme

Many templates give you access to variables, such as who is logged in at the moment. You can insert a valid variable into a template with the code {{$variable}} (changing the word "variable" for the name of the variable). You can only used variables that are already defined, otherwise it will give an error.

To find out what variables are available in a template, insert the following code in that template, and then visit any page that uses that template.

{{debug}}

This will cause a popup to appear for anyone who visits the page, showing you the available variables, and the data assigned to them.

As such, it is suggested that you only use {{debug}} on development or testing servers, not production servers.

Neuhub Documentation
documentation@neuhub.org
Neuhub Documentation
This channel has not added a profile description yet

Wiki Pages

Sorry, you have got no notifications at the moment...