History of ThemeTutorial

Version 43

ThemeTutorial

bitweaver Theming Tutorial

Created by: laetzer, Last modification: 18 May 2008 (20:33 UTC) by laetzer
This page is supposed to provide some information on how to create a theme for bitweaver.

There are some detailed informations on how the CssSchema is set up and how to use it without getting frustrated, cos "so many things change every time i change only one class".

Tips, Hints and Tricks

Applying Changes

As soon as you've made changes in your css file, they should be visible in your browser after you have reloaded the page ( usually F5 on windows or <ctrl-r> on linux ). If the changes don't appear
  • make sure you don't have any spelling mistakes ( syntax highlighting helps )
  • make sure you are addressing the correct class / id ( if need be, check the source of the page if the class / id exists )
  • make sure you are using the correct selectors ( a.external is not the same as .external a )
  • try using !important in your definition - e.g.: border:1px solid #000 !important;

Browser

Personally i use opera as the browser of choice due to it's state-of-the-art css and XHTML compliancy and the possibility to customise everything yourself. if you want to use opera, please visit Literary Moose's Opera Pages for information on how to turn your opera into an incredible designers tool.

for beginners, however, i recommend firefox and the webdeveloper extension. both of these browsers are cross plattform.

Pick an Appropriate Starting Theme

If you want to customise a theme according to your needs, you should pick a theme that more or less has a layout you wish to use. If you are a complete beginner, it might be useful to start with a theme that uses a table based layout as these are much more forgiving and much easier to set up. such themes include: basic, bitweaver, july4.

Most other themes use a div based layout system, which is more sophisticated to set up. If your changes, however, are minor, such as modifying the colours or the font-size, you should be able to pick one of these themes as well.

Source code

We use the smarty templating engine and we apply the {strip} tag to most templates to remove any excess whitespace characters. this reduces the download size of the html pages but also results in an html code that is very difficult to read. to make the source code readable, i recommend you change the following in your bitweaver install:

/util/smarty/libs/Smarty_Compiler.class.php line 335
from

<?php
335
$text_blocks[$j] = preg_replace('![\t ]*[\r\n]+[\t ]*!'''$text_blocks[$j]);
?>

to

<?php
335
$text_blocks[$j] = preg_replace('![\t ]*[\r\n]+[\t ]*!'"\n"$text_blocks[$j]);
?>


Note: Make sure to clear out your template cache after making the above change. if you don't you will not see any difference. (administration -> kernel -> system cache, and click "empty" on the line with /temp/templates_c)


The beginning

Getting started

All themes that are available on your site are located in /themes/styles/
Here you will find one theme called blank. This is a theme which contains all the most important classes and ids listed without any definitions.


Create a New Theme

Copy the theme 'blank' (or whichever theme you would like to modify) and rename the folder to your new stylename.
within <stylename> rename the original css file to <stylename>.css

<?php
hence we go from
/themes/styles/blank/blank.css
to
/themes/styles/<stylename>/<stylename>.css
?>


I will assume that you have copied /blank/ as a starting point
if not, please copy all the contents of /blank/ ( appart from blank.css and blank_commented.css ) to your new theme folder to take full advantage of this tutorial

Taken from /themes/styles/blank/readme.css

if you wish to create a theme from scratch here is a list of all css files present in /blank/ to aid you:
  • blank.css
    • main css file with all globally used classes and more
  • customisation.css
    • contains a list of classes that can be utilised to further customise the site
  • debugwithoutline.css
    • contains a set of classes and definitions that allow you to visualise all structures used on your site
  • showdiv.css
    • if included will visualise all divs used on the site including their classes and ids
    • (works well with debugwithoutline.css)
  • showstructure.css
    • like showdiv.css but it will show you all classes and structures appart from divs
    • (works well with showdiv.css and/or debugwithoutline.css
  • showsitelayout.css
    • visualises the layout of the main bit ids used by surrounding them with coloured lines
  • showpagelayout.css
    • draws coloured borders on one side of certain elements
    • to allow you to view the classes used without messing with your layout

Including css files in your main css file

o include one of these files in your theme for debugging purposes, you can insert a line at the top of your css file
@import url("include.css");

Do this for as many css files as you wish but note:
  • @import only works when it's before any definitions
  • showstructure.css | showdiv.css don't work with MSIE
    • use opera or mozilla to utilise these files
    • debugwithoutline.css only works with opera

I have tested the above with the following browsers:
  • MSIE 6.02 (nothing works regarding structures)
  • Mozilla Firefox 0.8 (everything works appart from debugwithoutline.css)
  • Opera 7.5 (everything works)

Template File Hierarchy

this is the order in which locations are checked for, for any given template:

themes/force/<package>/
themes/force/
themes/styles/<stylename>/<package>/
themes/styles/<stylename>/
<package>/templates/


This means that placing a file in themes/force will override any template found in any theme, makes it easy to create a common footer containing copyright information, without having to modify tonnes of files.

We recommend that you make a copy of any template file you wish to edit in your own style directory that the upgrade process to later versions is quick and easy.

Now we are ready to start with the css files.


The CSS

Introduction

If you are coming from TikiWiki, you will notice that the CSS is much smaller compared to that of TikiWiki and there are very much fewer classes used.

This, however has absolutely nothing to do with the flexibility and power of the CSS file over the design of bitweaver. in fact, it's much easier and quicker to create a site that has an overall feel throughout. moreover, it's easy to customise particular sections exactly the way you need them if you so desire.

A certain level of css knowlegde however is required to do this.

If you feel that you 'know' CSS you can use the 'blank' theme as a starting point for your new theme. Please consult the readme in the 'blank' folder for further information.

Please Note:
There is a file called base.css which is called by most themes using @import at the top of the css file. This css contains some definitions which make theming easier due to it's generic settings that set a base for difficult settings such as the css dropdown menus.


However, if you believe that there is something to be learnt from this brief tutorial, carry on reading... first of all it's important that you have a look at CssSchema, which has a basic layout of the site in terms of classes used on all output pages.

A Simple Example

1.
text

2.
text

3.
text


if you define the following:

.box { font-weight: bold; }


it will result in the following:
1. text
2. text
3. text

the text in all three cases will be bold, however, if you define it like this:

.box { font-weight: bold; }
.module { color: red; }
.admin { color: blue; }


it will result in the following:
1. text
2. text
3. text

this allows you to create a general style, look, feel using very few classes such as .box above (all the above are bold) but then go on and customise and finetune particular sections or groups of items simply.

Slightly More Taxing

furthermore, it's easy to modify classes that are defined within other classes using the correct selectors.

consider the following 2 pages:


<div class="wiki">
  <h1 class="title">pile of foo</h1>
  <div class="content">this is more foo</div>
</div>



<div class="articles">
  <h1 class="title">pile of foo</h1>
  <div class="content">this is more foo</div>
</div>


the above only differ in the first line - either wiki or articles. as above it's easy to aply general definitions to title, and content. however it's also possible to influence, say, the content section of articles without changing settings in the wiki by defining the following:


.articles .content { background: silver; }


The Nitty Gritty

consider the following page


<div class="box">zero plus two equals one</div>

<div class="foo">
  <div class="box">i can sing</div>
  <div class="foo box">some chickens have lips</div>
</div>


if you wish to apply a definition to all boxes you use

.box { text-decoration: underline; }


zero plus two equals one
i can sing
some chickens have lips


if you wish to apply settings only to the boxes within the foo section

.box { text-decoration: underline; }
.foo .box { font-weight: bold; }


zero plus two equals one
i can sing
some chickens have lips


if you wish to apply settings only to the box that has foo associated with it

.box { text-decoration: underline; }
.foo .box { font-weight: bold; }
.foo.box { color: red; }


the result of all three definitions would be
zero plus two equals one
i can sing
some chickens have lips


please note the lack of a space in the third case as compared to the second case.
'.foo .box' vs '.foo.box'


note for MSIE: MSIE only renders .foo.box {...} if this is the actual order in which they are mentioned. i.e. .foo.box {...}
only renders if the class is called:
class="foo box"
and not:
class="box foo"


obviously you can apply a setting to only the top box by setting definitions something like this

.box { color: blue; }
.foo .box { color: black }


zero plus two equals one
i can sing
some chickens have lips

as you can see, you have an immense amount of power if you wish to use these features.


Building the Theme

Well the first thing you'll probably want to start with is font style and background.

* {
  color: blue;
  font-family: sans-serif;
  font-size: normal;
  font-style: normal;
  font-weight: normal;
  text-decoration: none;
}
body {
  background-color: gray;
  background-image: url("images/background.jpg");
}


Take a look at CssSchema and see how you want to layout your site. Lets say you wanted #bittop to always be 120px high with a silver background, you'd set accordingly.

#bittop {
  background-color: silver;
  height: 120px;
}


Next, you'd like to set a border around #bitmain.

#bitmain {
  border: thin solid black;
}


more to come...


Slideshows

slideshows are a feature of the wiki and allow you to display the wiki page in a particular way without any excess information such as columns or banner.

the slideshow pages are set up in a similar way as the wiki page and use the same classes. you can pick a theme that will be used when displaying wiki pages as a slideshow.

if you would like to use your own theme as the style for slideshows but would like something like 'larger text', you can create slideshow.css in your theme directory and add all your definitions in there. this file will be loaded in addition to your regular css and you can thus override any settings made above.

also, there is a folder called slideshows. this contains some sample slideshow.css files, which you can copy (and rename) to your theme dir, saving you some time.

so, the easiest method to enlarge your slideshow text, is to create a file called 'slideshow.css' in your theme directory and then copy and paste the content of 'slideshows/enlargetext.css' to that file and save - voila!

just to illustrate, here is the content of enlargetext.css:

h1,.title {
  font-size: 2.4em;
  line-height: 120%;
}
.content {
  font-size: 1.3em;
  line-height: 120%;
}



Icons

In bitweaver it is possible to use your own set of icons to give the site the ultimate in customisation and theming flexibility.

currently it is possible to associate any icon with a given theme by creating an icon in the folder
/themes/styles/<style>/icons/<package>/

The extension of the icon has to be: jpg, gif, png. If a file with the same name as the original icon is found in the above location, it will override the original icon. This allows you to fully customise the feel of your site, even integrating icons in the mix, wihout you ever having to touch the source code. We use a custom set of smilies by overriding the original ones here on his site.


Style Information

I recently modified the theme selection page to display a theme specific image and a short description. To take advantage of this feature, you need to follow the following steps:
Create a folder called style_info in your theme directory. in there you can add a file called description.htm, which should contain a brief description of your theme in html format (XHTML 1.0 Strict).

The image for the theme needs to be named preview.<ext> (the extension doesn't matter. this can be any image format). As a standard, it would be good, not to exceede 160px width for the image.


The Templates

template files can be found in the directories <package>/templates. most of the templates have the same name as the php file, using .tpl as the extension. some specific .tpl files are only used as an inclusion and can't be used on their own. these are marked with an additional _inc at the end of the filename.

If you wish to edit any one of these templates, we recommend that you create a copy of the file in your theme folder and modify the copy there. The structure in the theme folder should be
/themes/styles/<style>/<package>/<template>.tpl
lazy sods can copy the templates into
/themes/styles/<style>/<template>.tpl
allthough there may be a risk of file name collision if two package templates have the same name.

Use the Force

If you would like to force the use of a given template for all themes but don't want to edit the source files, you can create a directory called force. Any templates found here, will override any other templates unconditionally.
/themes/force/<package>/<template>.tpl
once again, spastics can use
/themes/force/<template>.tpl

This is an excellent technique for creating a single top_bar for your site if you use multiple themes.

This will allow easy upgrading of your system if you should require this at some point.

more to come...


CSS Drop Down Menus

Tutorial - Native Theme
</style></stylename></stylename></ctrl-r>
Page History
Date/CommentUserIPVersion
30 Oct 2008 (17:12 UTC)
removed HTML before it's stripped out again, removed outdated CSS help, re-structured the whole page, less words
laetzer141.20.150.4345
Current • Source
charles75.160.109.23544
View • Compare • Difference • Source
laetzer85.178.10.6243
View • Compare • Difference • Source
xing194.152.164.4541
View • Compare • Difference • Source
Kozuch88.100.108.15940
View • Compare • Difference • Source
xing194.152.164.4535
View • Compare • Difference • Source
xing194.152.164.4534
View • Compare • Difference • Source
xing194.152.164.4533
View • Compare • Difference • Source
xing194.152.164.4532
View • Compare • Difference • Source
xing194.152.164.4531
View • Compare • Difference • Source
xing194.152.164.4530
View • Compare • Difference • Source
xing194.152.164.4529
View • Compare • Difference • Source
spiderr66.93.240.20428
View • Compare • Difference • Source
xing194.152.164.4527
View • Compare • Difference • Source
xing194.152.164.4526
View • Compare • Difference • Source
xing194.152.164.4525
View • Compare • Difference • Source
xing194.152.164.4524
View • Compare • Difference • Source
xing194.152.164.4523
View • Compare • Difference • Source
xing194.152.164.4522
View • Compare • Difference • Source
xing194.152.164.4521
View • Compare • Difference • Source
xing194.152.164.4520
View • Compare • Difference • Source
xing194.152.164.4519
View • Compare • Difference • Source
xing194.152.164.4518
View • Compare • Difference • Source
fire203.229.38.12417
View • Compare • Difference • Source
xing194.152.164.4516
View • Compare • Difference • Source
xing62.99.189.13015
View • Compare • Difference • Source