NoPic eZine
  
Home
Impressum/Imprint
Datenschutz/Policies
 
1.Issue 2006.06/1
 1.1.phpWebSite 1.0.0RC1 released
 1.2.Installing pWS 1.0.0rc1
 1.3.Running thru install
 1.4.First anonymous touch
 1.5.Exploring fallout surface inside
 1.6.Module substitution
 1.7.Directory Tree
 1.8.Database Tables
 1.9.ReadMe summary
   Access.txt
   bbcode.txt
   Cache_Lite.txt
   Categories.txt
   Clipboard.txt
   ControlPanel.txt
   Converting_Modules.txt
   Cookie.txt
   CREDITS.txt
   Database_Class.txt
   DB_Pager.txt
   Demographics.txt
   devdoc.modlayout.txt
   Developer_Rules.txt
   Editor.txt
   Forms.txt
   INSTALL.doc.txt
   Key.txt
   Known_Errors.txt
   Language.txt
   LICENSE.txt
   MiniAdmin.txt
   Mod_Rewrite.txt
   Module_Development.txt
   My_Page.txt
   README.doc.txt
   README.txt
   Related.txt
   Search.txt
   Settings_Class.txt
   SmartTags.txt
   Style_Format.txt
   template.txt
   Theme_Creation.txt
   Using_Javascript.txt
   Version.txt
   WYSIWYG.txt
 1.10.Using module WebPages
 1.11.Using module MenuManager
 1.12.Using webPages Editor
 1.13.Styling and Themes

    en

Categories.txt

Categories documentation
by
Matthew McNaney

Introduction
----------------------------------------------------------------------
Categories helps sort your module's information. This allows items
from different modules which share similiar characteristics to be
accessed together.


Getting Started
----------------------------------------------------------------------
I will be using the Blog Module for my examples. The word 'item' is
used as a generic description of what your module creates. For
example, Blog has a blog entry 'item'. A calendar module would have an
event 'item'.

I will be referring to two types of items in my descriptions. The
first item is your module's item. The second item is the category
item. The category item is just a link to your module's item. So for
each item in your module, category will retain some of its information
and then sort it.


The Category Menu
----------------------------------------------------------------------
There are two main steps to assigning your item to a category. First,
you need to include the category listing multiple selection box into
your form. Second, you need to catch the results of that form.

To retrieve the category multiple select input for inclusion into your
form, you need to first create a category item.


Creating a Category Item
----------------------------------------------------------------------
To associate your item to a category, you must first create a category
item object, like so:

$category_item = & new Category_Item('blog');

With 'blog' being your module's title.


Setting the Category Item Variables
----------------------------------------------------------------------
The category object item needs a link to your item. You must assign an
id to the category. This id will could be your module item's id, the
id of the current version* of your item, or both.

To set your module's item id:

$category_item->setItemId($blog->id);

If my module's item is actually a version of the original or an
unapproved version, I will also set the version id:

$category_item->setVersionId($version_id);

Getting the Category Form List
----------------------------------------------------------------------
The category item object needs just the above ids in order to create a
selection menu. To get that menu, I call getForm:

$template['CATEGORY_LISTING'] = $category_item->getForm();

This tag must be in the middle of the form's beginning and end
tags. For example, if you are using phpwebsite's form class:

{START_FORM}
.
.
Pick one or more categories for this entry
{CATEGORY_LISTING}
.
.
{END_FORM}


Saving the Results
----------------------------------------------------------------------
After submitting your module's form, you need to catch the category
results. 

First create your category item object:

$category_item = & new Category_Item('blog');

Where 'blog' is your module's name. Now you need to load your category
item. The first two are familiar.

$category_item->setItemId($blog->id);
$category_item->setVersionId($version_id); // if using versioning

There are two other parameters that need setting.

$category_item->setTitle($blog->title);

The title is what is seen when your module's item is seen in a
category listing.

$link = 'index.php?module=blog&action=view&id='
. $blog->getId();

$category_item->setLink($link);

* Use '&' instead of '&' in your links to make it XHTML compliant.









* See Version.txt for information on versioning.


    en

Copyright © 2006, VbID Verlagsbüro GmbH
pWS modules dcP, dcT, dc4db, Copyright © 2006, VbID Verlagsbüro GmbH
This Site is powered by phpWebSite © The Web Technology Group, Appalachian State University