What is Category Set?

The category set is a technique to help categorize the information in the system.

Category Set plays two basic roles.

  1. Manage Categories Linearly or Recursively
  2. Help others to categorize information

This is very useful for managing any type of category effortlessly. Category sets are created through XML files containing all necessary configurations. Below are the methods to create a category set.

Method 1: Work in the base framework

All the files are typically saved in the below location

development/definition/cateogry_set

Here are some important points to follow:

  • Each XML file is considered a category set.
  • The name of the XML file is considered the categorySet name.

To create a category set, simply create the XML needed in the above location, and it's ready to use. See below example:

<?xml version="1.0" encoding="utf-8"?> <CategorySet> <base> <version>0.1.0</version> <lastupdate>2023-12-01</lastupdate> <title>Blog Category</title> <admin_tab>blog</admin_tab> <parameters/> <description>Yes</description> <image> <status>No</status> <type>Single</type> </image> <haschild>Yes</haschild> <generic> <status>Yes</status> <title>Sort Order</title> </generic> <sreach> <status /> <field-selected /> <parma-link> <type /> <uri /> </parma-link> </sreach> </base> </CategorySet>

Below is some common fields information to keep in mind

TagDescriptionExample
titleTitle of the category setBlog Category
admin_tabThe interface builder tab to render the UIblog
descriptionEnable/Disable description fieldYes
imageEnable/Disable ImageYes
haschildEnable/Disable sub categoryYes
genericEnable/Disable an additional field. Title help to define name of the fieldYes

Click here to find more about field definition.

Now, the category set needs to be accessed from the admin pane. Below are the access links to manage the data in the category set

TypeConvention Example
Add Entrycategory/manage/[name]/add/td>category/manage/blog-cat
Manage Entriescategory/manage/[name]category/manage/blog-cat

* [name] is a category set name. More about the access link is here.

Through Interface Builder, the UI can be accessed from the admin panel. Follow the below XML to add the menus.

<menu> <title>Blog Categories</title> <items> <item> <title>Add Category</title> <link>/category/manage/blog-cat/add</link> </item> <item> <title>Manage Categories</title> <link>/category/manage/blog-cat</link> </item> </items> <adminicon> <type /> <location /> </adminicon> </menu>

A component always keeps all its resources isolated in the component folder. So the XML file should be placed inside the working component directory. See below for the path.

component/[component name]/category_set

For example, if the component name is “appbog” and the category set name is "blog-cat," then the file should be created in the below location:

component/[component name]/blog-cat

After file creation is done, the category set needs to be registered in the component through the callback method in the next two steps.

Step 1: Register the Callback

<?php class Component_Homepress_Register extends appRain_Base_Component { public function init() { App::Module("Hook") ->setHookName("CategorySet") ->setAction("register_definition") ->Register(get_class($this),"register_categoryset_defination"); } }


Step 2: Execute the callback

<?php class Component_Homepress_Register extends appRain_Base_Component { public function register_categoryset_defination() { $srcpaths = Array(); $srcpaths[] = array( "type"=>"blog-cat", "path"=>$this->attachMyPath("category_set/blog-cat.xml") ); return $srcpaths; } }


Function Reference

It is always expected that Framework can access data and use it. Below are the methods that help to work with cateogry set through programming.

Find FindByField findAll
findAllByField Listing getRecursive
Parents Tag Save


Summary

As a CMS tool it helps to manage category through an auto-generated interface. Let's recap.

  • First, create the XML file with all the required fields.
  • Second, if it’s a component, create the file inside the component directory; otherwise, in the development area.
  • Finally, set the menu in the admin panel to access the user interface and manage data.

Important: All data in the category set is driven by the mode Category. So that can be accessed through this model as well.