|
Table of Contents
Theming guide (pluck 4.7)This page will guide you through the process of making your own pluck-theme. You have to know your way around (X)HTML, and CSS. Knowledge of PHP is not required. Converting pluck 4.6 themesThe theming system in pluck 4.7 is slightly different from the older system in pluck 4.6. Converting a pluck 4.6 theme for use with 4.7 is very easy, and requires only a few minutes of work. You will have to adjust the following two functions:
Directory structureEach theme has its own directory in data/themes. Your can make your theme in data/themes/blue, for example. There are at least 3 files needed in a theme-directory:
We'll go through these files one by one. The following file is optional:
style.cssThis isn't very difficult: every theme needs a CSS-file. It's important that the name of the file is style.css, because the file will be included in the (X)HTML-code automatically. It's not necessary to include the file yourself. Pluck uses a few style-objects to theme some objects. You can use the following objects in your css-file if you wish to enhance your theme further:
theme.phpThis is the most important part. Here, you will specify the (X)HTML-code for your theme. In this file, you can just put plain (X)HTML, no problem. However, you'll have to add some PHP-functions to include page-content, page-title and so on. Let's look at the PHP-functions we need to include. PHP-functionstheme_meta()<?php theme_meta(); ?> This one, you can just put between your <head>-tags. It will input the following things:
Pluck also provides you with the option to automatically include a CSS Reset file. To do this, use the function like this: <?php theme_meta(true); ?> theme_sitetitle()<?php theme_sitetitle(); ?> You can put this anywhere in your theme. It displays the title of the website. theme_pagetitle()<?php theme_pagetitle(); ?> You can put this anywhere in your theme. It displays the title of the currently viewed page. theme_menu()<?php theme_menu($block, $inline, $active_id = null, $level = 0, $only_subpages = false); ?> This one is important. It will display the menu-items. This is what the variables do:
Let's give an example. If we use the following code: <?php theme_menu('ul', 'li', 'active', 0); ?> The following HTML-code could be generated: <ul> <li id="active"><a href="?file=home">Home</a></li> <li><a href="?file=about">About</a></li> <li><a href="?file=contact">Contact</a></li> </ul> theme_content()<?php theme_content(); ?> You can put this anywhere in your theme. It displays the content of the currently viewed page. theme_area()<?php theme_area('nameofarea'); ?> One reason why pluck is so flexible, is that it features modules. These modules can be added to some different areas in the website. With this PHP-function, you can define where modules can be added to your theme. That way, a user can add a module to all pages on his website at once. For example, if you have a sidebar in your theme, it's possible that some user wants to include an advertisement at that spot on all pages, with an advertisement-module. He can only do this if you define that it's possible to add a module there, with the following code: <?php theme_area('sidebar'); ?> You see, that you can change nameofarea in a short name that describes the place best. ExampleTake a look at the example below if you don't fully understand the module-part yet. It will be more clear then. We will take a look at an existing theme, and we'll show how we port it to a pluck theme. This is the (X)HTML-code we have to port: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Home - website</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> </head> <body> <div class="wrap"><div class="header">Site title here</div> <div class="menu"> <ul> <li id="active"><a href="home.php">Home</a></li> <li><a href="about.php">About</a></li> <li><a href="contact.php">Contact</a></li> </ul> </div> <div class="content"><h1>Home</h1> <div class="txt">These are the contents of the page</div></div> <div class="sidebar">Here, we include some things like advertisements or polls. </div> <div class="footer">theme made by <a href="#">me</a></div> </div> </body> </html> Now, we'll port the code by stripping the tags from the head, and add the theme_head(); function there. We also change the site title, page title and page content with functions. Then, we add the theme_menu(); function, using the code of the menu-items. Then we see a nice place for modules: the sidebar. So there we put a theme_area();. We also put a module-space with the name main just after the content, and one in the footer with the name footer. This is the resulting code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<?php theme_meta(); ?>
</head>
<body>
<div class="wrap"><div class="header"><?php theme_sitetitle(); ?></div>
<div class="menu">
<?php theme_menu('ul', 'li', 'active', 0); ?>
</div>
<div class="content"><h1><?php theme_pagetitle(); ?></h1>
<div class="txt"><?php theme_content(); ?></div>
<?php theme_area('main'); ?>
</div>
<div class="sidebar">
<?php theme_area('sidebar'); ?>
</div>
<div class="footer">theme made by <a href="#">me</a>
<?php theme_area('footer'); ?>
</div>
</div>
</body>
</html>
info.phpIn this php-file you specify some important information about your theme. The following two variables need to be included:
<?php $themedir = 'blue'; $themename = 'Nice Blue Theme'; $module_space[0] = 'main'; $module_space[1] = 'footer'; $module_space[2] = 'sidebar'; ?> |