====== Theme Mini-HowTo ======
Bene, il mio suggerimento è di partire sempre da un tema già fatto, ed in particolar modo in questo momento dall' ultima versione //unstable// (basta usare il tema //flatmaas// e cambiare il CSS); infatti quando verrà rilasciato il nuovo pacchetto il tema risulterà un po' cambiato (comunque anche quelli vecchi funzioneranno) [[https://goo.gl/Kh6ih6|d'lemonie harga]].
Ok, vediamo come funziona.
===== Cos' è Smarty ? =====
[[http://smarty.php.net|Smarty]] è un sistema che traduce //template// contenenti speciali //tags// in php; la maggior parte dei blog usa semplicemente PHP, perché php è in effetti un linguaggio di template. Usare Smarty ci permette di astrarre dalla logica di programmazione di php, e dovrebbe rendere più facile progettare un template anche a chi non è un programmatore.
Tuttavia ci sono alcune cose da conoscere.
===== Struttura di un tema =====
**index.tpl** è il file "principale" per la costruzione di un tema. Questo contiene tutto ciò che che comparirà nella pagina index.php.
Prima di tutto create una nuova directory in //fp-interface/themes/// e copiate da //flatmaas2// il file theme.conf.php, o il file theme_conf.php (dipende dalla versione), nella nuova directory.
Ora scrivete il file index.tpl, un esempio è il seguente:
Published on {$date|date_format}
Bene, probabilmente eravate già a conscenza di come scrivere una pagina in html... ok aspettate. Ora che avete la vostra pagina, salvatela col nome index.tpl, controllate che nella nuova directory vi siano i permessi di lettura per tutti gli utenti, puntate con il browser su http://yourweb/flatpress/, andate nel pannello di controllo e selezionate dalla pagina di configurazione il nome del tema appena creato!
Salva e ricarica la pagina. Ora **è probabile che riscontriate un errore** perché al tema mancano alcuni file. Non c'è problema comunque, puntate nuovamente il browser su http://yourweb/flatpress/ e dovreste vedere la scritta "hello world".
Bene, questo è un buon inizio.
===== 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.