To create a new Part you'll need to make a new directory in site\parts\. Name the directory a short name that you will call your part.
Inside the directory, create two files:
info.php - This will contain a information about your part that TextSide will use to install it. This includes a user friendly name and author information.
partName.php -
Where "Name" is the same name as your folder. For example: "partLogin.php". This will contain the actual code for your part. (More on this in a bit)
You should organize your resource files (images, css, javascript, templates, etc.)
the same as CodeBehind pages. They should be placed in a separate folder named /bin within your parts directory.
All together, your parts folder will look like this:
partname/
|--partPartname.php
|--info.php
|--bin/
|-- files/
|-- images/
|--icon.png <-- optional (see below)
|--screenshot/
|--small.gif <-- optional (see below)
|-- css/
|-- javascript/
|-- templates/
The info.php file contains basic information about your part. Heres a sample for a part :
<?php
//A user friendly name for this part
$name = "Current Time";
//A short description for this part.
$description = "A simple part that displays the current server time.";
//who created it
$createdBy = "Scott Bailey";
?>
The part
Name.php file (where Name is the same name as your part's folder) contains the actual code for your part. Here you create a new class named part
Name (again, the same name as your part's folder) that extends from the base class "part".
Within the class, you'll need to create, at minimum, a single View Handler (a function that knows how to render the parts content), and a member variable $defaultView that points to this View Handler. (View Handlers will be covered in more detail in the next section).
Heres an example of a bare minimum part that would display the current time:
<?php
class partTime extends part {
//the view that should be shown by default
var $defaultView = "Content";
/* View Handler - Content */
function viewContent(){
$time = date("F j, Y, g:i a");
return "$time";
}
} ?>
Here is an image of the above part in edit mode:
The rest of the documentation on Parts will go into detail on more advanced code for your Parts directory. A good starting point from here is
Part View Handlers.
If you'd like an Icon for your part, you'll need to add an a file called either
icon.gif or icon.png in your part's
bin/images directory.
A good resource for icons is the
Fam Fam Fam Silk Icon Pack
If you'd like a preview for your part in the Part Library, you'll need to create a file called
small.gif in your part's
bin/images/screenshot directory.