iWare Forum
February 06, 2012, 12:47:14 am *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Creating a skin  (Read 1955 times)
Administrator
Administrator
*****
Posts: 26



View Profile WWW Email
« on: May 21, 2008, 10:32:37 am »

iWare Skins SDK
We have attempted to make the creation of customized skins as painless as possible. This small guide will aid in the creation process, a basic knowledge of HTML at a minimum is assumed of course and those familiar with coding in PHP will have an easier time working with the navigation for example.

Overview
A "skin" consists of 3 required files contained within a directory beneath the skins/ directory of the iWare installation. The 3 files: skin.php, skin.js, and skin.css control the overall visual appearance and layout of the site. Below we will examine each file in detail providing examples and starting with the most important file first: skin.php

skin.php
This file contains the basic HTML and text to make up 99% of your layout. Take a look at the example provided below:

Code:
<body bgcolor="#ffffff" text="#000000">
< ?php echo $IW->Client_GetHeader(); ? >
< ?php echo $IW->Client_GetContent($_REQUEST['D']); ? >
< ?php echo $IW->Client_GetModule($_REQUEST['D']); ? >
< ?php echo $IW->Client_GetFooter(); ? >
</body>


This is as simple as you can possibly get when creating a skin. Notice that the file starts and ends with the HTML body tags and excludes the HTML, HEAD ? etc. This is on purpose of course as these other tags for your pages are created automatically.

In the example provided above we create a white HTML page with black text, and then subsequently make several calls to methods encompassed within the iWare class designed to output data for the pages of your site.

First we call Client_GetHeader() which simply outputs the header data into your page. Then we call GetContent () to load the pages contents, GetModule () to load a pages embedded module if one is present, and finally the GetFooter () which is identical to GetHeader () in the aspect that it simply outputs the footer content into the HTML page.

skin.css & skin.js
These files are extremely simple being that skin.css should contain any CSS code specific to your skin and skin.js should contain any JavaScript code specific to your skin. These two files will be read into each pages HEAD ? /HEAD at run time.

Adding Navigation
Adding the navigation to your skin is completely dependant on what you would like to achieve, but for simplicity and case of example we will be demonstrating here how to render an outline view that is recursive. Take a look at the example provided below:

Code:
< ?php
function Recurse ($id)
{
global $IW;
$sql="select * from ".TABLE_DOCS." where parent_id='".$id."' ";
$sql.="and is_active='1' ";
$sql.="order by nav_order";
$result=$IW->DB_Query($sql);
for($i=0;$i<$IW->DB_CountResult($result);$i++)
{
echo "<dir>";
echo "<a href=\"?D=".$IW->DB_Result($result,$i,"id")."\">";
echo $IW->DB_Result($result,$i,"link_text")."</a><br />";
Recurse ($IW->DB_Result($result,$i,"id"));
echo "</dir>";
}
$IW->DB_FreeResult($result);
}

function TopLevel ()
{
global $IW;
$sql="select * from ".TABLE_DOCS." where parent_id='0' ";
$sql.="and is_active='1' ";
$sql.="order by nav_order";
$result=$IW->DB_Query($sql);
for($i=0;$i<$IW->DB_CountResult($result);$i++)
{
echo "<a href=\"?D=".$IW->DB_Result($result,$i,"id")."\">";
echo $IW->DB_Result($result,$i,"link_text")."</a><br />";
if($IW->Docs_HasSubDocuments($IW->DB_Result($result,$i,"id")))
{
Recurse ($IW->DB_Result($result,$i,"id"));
}
}
$IW->DB_FreeResult($result);
}

TopLevel ();
? >

The above example consists of two defined functions: TopLevel () and Recurse (), These two functions will recursively display all active documents defined in the database as an outline view of text hyperlinks. The basic concept is that TopLevel () is called first, once it has started it will then loop through each topmost level documents checking each to see if they have any sub documents defined beneath them. If they do, then the function Recurse () will be called for that document which repeats the process at the next "sub level" of documents.

Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.15 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!