-
Notifications
You must be signed in to change notification settings - Fork 35
How to Make A NoNonsense Forum Theme
- Begin by downloading and installing NoNonsense Forum as per INSTALL.txt
-
I’ve prepared a special release for theme development you can [download here] (http://camendesign.com/_stuff/NNF_themedev.zip)
-
If you're on Windows, you can [download a pre-configured web-server with NoNonsense Forum installed] (http://camendesign.com/_stuff/NNF_easyphp_themedev.zip) to get yourself going quickly and easily: just run the exe, open your web browser to
http://localhost
and you’re ready!
-
Each theme is a folder within the "/themes" directory. You should never modify the default theme except for through "theme.config.php" because you would prevent yourself from updating NoNonsense Forum in the future. It is best for you to work from a copy of the default theme.
-
Make a copy of the "greyscale" folder within "/themes"
-
Rename the folder to whatever you want your theme to be called.
It's best to stick to URL-safe letters such as a-z, 0-9, underscore and no spaces
Now we must tell NoNonsense Forum to use your new theme. The name of the default theme is stored in "[/config.default.php] (https://github.com/Kroc/NoNonsenseForum/blob/master/config.default.php)" but you must not edit that file (otherwise you will not be able to update NNF).
-
Make a copy of "[/config.default.php] (https://github.com/Kroc/NoNonsenseForum/blob/master/config.default.php)" and rename it "config.php",
NoNonsense Forum will now override the defaults with the options set in "config.php" and your configuration will persist between updates -
Open "config.php" and change the value of the
FORUM_THEME
option from "greyscale" to the name of your new theme. It should look something like this://folder name of the theme to use, in "/themes/*" @define ('FORUM_THEME', 'my_theme');
-
Save "config.php" and refresh your browser where NoNonsense Forum is running; if all is correct nothing will happen! No errors mean that NoNonsense Forum is now running from the new theme, which is -- for the moment -- an exact copy of the default theme.
If you get an error message that the theme cannot be found, verify that the name of your theme folder is the same as is in "/config.php"
Within a theme folder are a number of files for different purposes. Here is a list and brief description of each to give you an overview of what you'll be working with
-
[img/] (https://github.com/Kroc/NoNonsenseForum/tree/master/themes/greyscale/img) [folder]
A place for the images in your theme. This is arbitrary and decided by your HTML / CSS, so you can choose to use a different name or location for your images if you so desire -
[index.html] (https://github.com/Kroc/NoNonsenseForum/blob/master/themes/greyscale/index.html)
Template for the 'index', the list of threads in the forum or sub-forums; essentially the 'home page' -
[thread.html] (https://github.com/Kroc/NoNonsenseForum/blob/master/themes/greyscale/thread.html)
Template for threads: the post and replies -
[append.html] (https://github.com/Kroc/NoNonsenseForum/blob/master/themes/greyscale/append.html)
Template for the append page (when a user is adding text to an existing post) -
[delete.html] (https://github.com/Kroc/NoNonsenseForum/blob/master/themes/greyscale/delete.html)
Template for the delete page (when a user is deleting a thread or reply) -
[markup.html] (https://github.com/Kroc/NoNonsenseForum/blob/master/themes/greyscale/markup.html)
Template for the documentation of the markup formatting used by NoNonsense Forum -
[privacy.html] (https://github.com/Kroc/NoNonsenseForum/blob/master/themes/greyscale/privacy.html)
Template for the privacy policy page -
[theme.css] (https://github.com/Kroc/NoNonsenseForum/blob/master/themes/greyscale/theme.css)
Obviously, the CSS for the theme. This file name is not mandatory, it's determined by what you use in your HTML, so you can have a different name / location if you so desire -
[theme.php] (https://github.com/Kroc/NoNonsenseForum/blob/master/themes/greyscale/theme.php)
A set of templating functions unique to your theme. Whilst you will not need to modify this to make a theme, doing so will give you advanced control over some features and allow you to create a different style of page links and moderator names list which, unfortunately, are not part of the HTML templates -
[theme.config.default.php] (https://github.com/Kroc/NoNonsenseForum/blob/master/themes/greyscale/theme.config.default.php)
Default configuration for your theme. The user of your theme can override this with a copy named "theme.config.php" -
[lang.example.php] (https://github.com/Kroc/NoNonsenseForum/blob/master/themes/greyscale/lang.example.php) [optional]
A sample file for doing translations of the theme. Details of this are not covered in these instructions, read the contents of "[lang.example.php] (https://github.com/Kroc/NoNonsenseForum/blob/master/themes/greyscale/lang.example.php)" for further instructions on translations. Whilst you don't have to translate your theme, "lang.example.php"'s contents should be updated to match your theme so that others can translate it themselves. If you are not going to use this file, it's best to delete it -
[favicon.ico] (https://github.com/Kroc/NoNonsenseForum/blob/master/themes/greyscale/favicon.ico) [optional]
An icon file to represent the site in a tab / title bar / bookmark. Note that this file in the theme is not actually used as such, but is provided for site admins to copy to the root of NoNonsense Forum where it will work. If you don't plan to make your own "favicon.ico" it's best to delete this file -
[apple-touch-icon.png] (https://github.com/Kroc/NoNonsenseForum/blob/master/themes/greyscale/apple-touch-icon.png) [optional]
A 144x144 image to serve as a launcher icon on mobile devices when users add the site to their devices' home screen. As with "favicon.ico", this file is not used directly and provided only for site-admins to copy & paste to the forum root should they want to use it. If you don't plan to make your own "apple-touch-icon.png" it's best to delete this file -
[metro-tile.png] (https://github.com/Kroc/NoNonsenseForum/blob/master/themes/greyscale/metro-tile.png) [optional]
An image to be used as an icon in Windows 8 when the user pins the site to their Start Screen. As with the other icons, this file is not used as such but provided for the site admin to copy if they want to use it. This image must have a transparent background.Warning: Due to a bug in Windows 8, this image must be a 32-bit PNG file. An 8-bit + Alpha PNG will not render. Some PNG optimisation software will automatically convert 32-bit PNG files to 8-bit where possible so be aware. If you are not sure about any of this, or you won't be providing your own "metro-tile.png" then it is best to just delete this file
Now that you have your theme set up you can begin to make changes to turn it into something of your own.
"index.html", "thread.html", "append.html", "delete.html", "markup.html" & "privacy.html" are the templates for the theme.
They are just regular HTML with no {{special syntax}}
embedded or the like that you have to understand.
The [templating engine] (http://camendesign.com/dom_templating) in NoNonsense Forum works by removing parts of the template that are not needed. Therefore the templates contain all the possible chunks of HTML for various situations. This means that everything you as a developer need is all on the one page and you can swap around the HTML and CSS all you want.
You can view the template, with all elements visible by visiting the HTML file directly through your web server, i.e. http://localhost/themes/greyscale/index.html
(but note to change "greyscale" for the name of your theme)
-
IDs and classes prefixed with "
nnf_
" are required as they are the hooks by which the template engine knows what elements to keep and what to remove. However, apart from the exceptions noted below, the type of element (e.g.div
,strong
,ol
) those IDs and classes are on can be changed; e.g. you can change<strong id="nnf_example">
to<em id="nnf_example">
- Hyperlinks (
<a>
) because of thehref
attribute -
<time>
because of thedatetime
attribute -
<input>
,<textarea>
for input forms -
<option class="nnf_lang">
because the language selector must be a select box at this time (if there is call from developers to allow custom language selectors then I will add support) - The submit buttons must be of
type="image"
otherwise you will not be able to post, sorry about this
You may add wrapping elements, change the order of anything and generally mess about with the HTML to a surprising degree. Exercise some creativity, but if you are not familiar with NoNonsense Forum yet it is best to refresh the page after each change to ensure that the layout hasn’t broken. If you need any assistance with creating NoNonsense Forum themes, you can ask questions in the [Camen Design forums] (http://forum.camendesign.com)
- Hyperlinks (
-
Each HTML page is complete, so there is a lot of duplication. This is done so that it is immediately clearer to anybody examining the HTML what the complete picture looks like, rather than having to chase lots of separate files around. Try focusing on one file first and copy across changes once you are happy. You should note the following subtle differences between files:
-
Only "index.html" has an about section (
#nnf_about
) that appears as a banner at the top of the forum if "about.html" exists; see the section on "Adding a forum introduction" in [INSTALL.txt] (https://github.com/Kroc/NoNonsenseForum/blob/master/INSTALL.txt) -
"append.html", "delete.html", "markup.html" and "privacy.html" do not have an RSS feed in the
<head>
-
"append.html" and "delete.html" have a robots no-follow in the
<head>
to tell search engines not to index these pages
<meta name="robots" content="noindex, nofollow" />
-
-
It is important to note that whole sections will appear or disappear depending on the situation, for example the language selector is removed from the HTML entirely if no translations are available. In the default theme this has a distinct effect on the navigation breadcrumb and the RSS / Add link. Be sure to test the theme using the various permutations
-
The list of pages on "index.html" / "thread.html" is not generated from the template (they're there for the purposes of testing CSS), instead the page list is generated by a function in "[theme.php] (https://github.com/Kroc/NoNonsenseForum/blob/master/themes/greyscale/theme.php)". This is done so that, should you want to, you can change the type of page list (a drop-down box instead perhaps) which requires programatic changes
-
The lists of mods / members (
#nnf_mods-local-list, #nnf_mods-list, #nnf_members-list
) are not generated from the HTML templates, they are generated by a function in "[theme.php] (https://github.com/Kroc/NoNonsenseForum/blob/master/themes/greyscale/theme.php)", this is because you may want to build the list in a more complex fashion than the templating engine alone may allow