====== Theme Mini-HowTo ======
Well, my suggestion is always to start from an already made theme, and at this moment I would start from latest unstable version (using flatmaas theme, and changing the css); when I'll release the new package themes will be a bit changed (even though old ones should still work).
Ok, let's see how it works.
===== What is Smarty ? =====
[[http://smarty.php.net|Smarty]] is a system which translates //templates// containing special //tags// into php; most of the blogs you see around just use PHP as php itself works actually like a templating language. Using Smarty let us **abstract** more from the php programming logic, and should make easier for non-programmers to design a template.
However, there are some things people should know.
===== Structure of a theme =====
**index.tpl** is your "main" file. It must contain all of the stuff which will go in index.php
First of all create a new dir in your fp-interface/themes/ dir, and copy from flatmaas2 the theme.conf.php (or theme_conf.php depending on your version) to the new directory.
you could create a index.tpl like this
Published on {$date|date_format}
Now, you would probably be all "I know how to write an html page, you idiot!", well wait. Now that you have your dumb hello world page save this
index.tpl, check whether you really have reading permissions for all users on that directory, and then point your browser to flatpress, go to control panel and select from the config page the name you chose for the dir of your theme.
Save, and refresh. Now **you'll probably have an error** because the new theme lacks some stuff. No problem, just browse to http://yourweb/flatpress/ as an index you should see your hello world.
Well, that's a good start.
===== Populating with entries =====
ok, let's go on. Now you would probably like to populate your (naked) page with some content, don't you? Well, I'm assuming you already have some entries, so let's go on.
{entries}
Well, there you go, you're already done. Save and reload. You should see
your posts.
But let's see what all of this mess does.
===== Preamble tags: entries =====
First of all we have this outer smarty tag called **{entries}** (0.703+ will call it {entry_block}, "entries" it's too similar to the inner "entry", but let's go with some order...).
We could call this tag a //preamble//. We have this approach with other FP tags, which I'm not gonna show you now because they're similar in behaviour but really it's because I have no time (the suggestion is looking at the other themes, once you've finished with this reaaaaally quick tutorial).
What is a preamble? well, from the point of view of the designer a preamble has really little meaning, actually :P
> **A preamble marks an area on your page where you want an auto-generated content to appear.**
In this case we're telling flatpress that there we want to put a group of entries. In {entries} we can put a container {$subject}
{entries}
{entry}
{$subject}
Published on {$date|date_format}
{$content}
{/entry}
{nextpage}{prevpage}
{/entries}
Here they are, before the {/entries} closing tag and after the iterator
block. There are technical reasons for it to be there, but we won't explain
them now.
Our header is still a bit boring:
header.tpl
-----------------------
hello
and the rest of the page:
index.tpl
-------------------------
{*
hi I'm a comment, and what follows
is an include directive
*}
{include file=header.tpl}
{entries}
{entry}
{$subject}
Published on {$date|date_format}
{$content}
{/entry}
{/entries}
This will tell smarty "hey, in the same dir of the templates look for a file
called header.tpl and put it here!".
you can even use relative (or absolute) paths; let's imagine you have a tpl
dir in your theme dir:
{include file=tpl/header.tpl}
however, we conventionally put tpls in the "root" dir, and we put misc stuff
in res/; images should go in imgs/ (yes flatmaas2 called it "images" I
should change it ;))
file= admin also a special "URL-like" syntax.
file=shared:my_template.tpl will look for a template called my_template.tpl
in fp-interface/sharedtpls/
This is used to display special administrative controls/links or the comment
form.
===== Adding some color =====
let's move back to the theme dir; create a res/ directory and put there a
style.css; now you can open it and and style a bit your page. Of course you
can add divs (and tags) as you like to be able to style whatever and in
whichever way you want.
===== Adding widget bars =====
Finally, let's go with the final important reason for which you're going
crazy: how the heck can I have a three-column layout?
Ok, to start put in the end your index.tpl the widget code:
{widgets pos=left}
{$subject}
{$content}
{/widgets}
{widgets pos=right}
{$subject}
{$content}
{/widgets}
Notice you don't have a preamble as you usually always want to see the divs
of the right/left bar
Now you'll probably have an empty bar on the left, because FP uses just the
right one :p Once you're done with the admin panel you can populate the left
bar as well (if you don't want to wait you can edit the plugins.conf.php and
widgets.conf.php you find in fp-content/config/ by hand because that's
actually what the admin panel does...).
Finally you will probably want to have the widgets on each page of your
design (excepted maybe the control panel) so move the whole bar in a
widgets.tpl and put in index.tpl the directive {include file=widgets.tpl}
Here you go.
Now you're almost ready to start exploring th FP theme engine.