Why and How creating new types in Kneaver

Why and How creating new types in Kneaver


Customization is a compelling feature of Kneaver. With types you can smoothly enhance the semantic capabilities of Kneaver. In this post I took the occasion of creating a new type to show the process step by step.

Customizing a single item

I am on the process of collecting my knowledge on KM itself. For this I follow our hint “#5 List Knowledge Sources”. I create an item, set its type as “KNV:Container” and start adding name of people there : Bloggers, Writers. When I use Kneaver I am following my associations freely. I read a blog post and I will add the name of the blogger, the address of the blog. It is in the middle of this task that I added an “Organizations ” container and linked “Peoples ” to “Organizations ”.

That’s where I realized the need to sort the list of people automatically and list first the people before any other link, otherwise links to Organizations would be right in the middle.

I used The template gallery to find a solution.

It’s easy, suffice to place a template call in the body of the container to list people. Since items will not be listed twice this will cause people to be listed before anything else.

This is the template call in Kneaver Syntax. [object Object] will surround any template call similar to [[ ]] surrounding a wiki link. | separates template arguments.

{{ KNVItemLinksByTypeOrderByGroupBy knv:persontype | Name | | }}

This is the dialog to edit the “people ” topic:

Image-2013-03-14-0151-Scr

This is the result

Image-2013-03-14-0148-Scr

Now I thought that it would be the same for containers of people in Software design, in Marketing. This is where we realize the benefit of introducing a new type. If you can easily find a name to characterize several items and they are going to share some behaviors or could be used in similar ways it’s better to make a type. The Type name will be precisely this name you found. In my case I choose “Yellow Page” and the type is “KNV:YellowPageType”. It is prefixed by “KNV”, this is the Kneaver namespace because I plan to eventually move it into an application so that every Kneaver use will find it. Applications can be shared among Kneaver sites. You can make applications as well.

At this stage we understand the need and the benefits of types and we wish to put it in practice.

How to practically create a new type

As simple as creating a new item.

  1. Go to the dashboard
    1. Select the tab “Types” in the right widget.
    2. Scroll to the type you want to specialize, likely the type of the object you want to generalize. In our case “KNV:ContainerType”
      Image-2013-03-14-0145-Scr
    3. Click on the ”+” icon. On older version of Kneaver you may have to right click and select “Open in new window”.
  2. Now you are on the “Kneave” Dialog to create an item.
    Image-2013-03-14-0146-Scr
    1. Make sure the type is “KNV:TypeType
    2. Make sure the Link type is “KNV:InheritanceLinkType”8. Press “Create Item” button
  3. Now you are in the “Add Item” Dialog
    Image-2013-03-14-0147-Scr
  4. Done, the new type can be used instantly

Go back to the item whose type you want to change, use the combo and select the type you just created

Image-2013-03-14-0151-Scr

Now change will occur on the display, we have a new type but no behavior attached to it.

Let’s define a template for it.

Defining a template for a type

There is a template file already defined for each project:

Image-2013-03-14-0152-Scr

Open it with a text editor (some environments allow to edit the file remotely). It is a kind of php/html file. Scroll to end, before </body>.

Image-2013-03-14-0153-Scr

We are overloading the template call KNVItemLinks called when Item links are displayed. the best is to locate it from the existing one and copy it.

Image-2013-03-14-0155-Scr

and add ”.KNV:YellowPageType” at the end of the name (replace KNV:YellowPageType by your new type name).

Image-2013-03-14-0155-Scr

Let’s save the file and refresh the item in the browser. As usual effect is immediate but since the new template is the same as the existing one nothing can be seen, as before the direct call to links in the body has priority.

Image-2013-03-14-0156-Scr

How can we see the difference ?

  1. Remove the template call in the item.It is not necessary any more.
    Image-2013-03-14-0151B-Scr
  2. Modify slightly the template in the file
    Image-2013-03-14-0159-Scr

Refresh, it’s done

Image-2013-03-14-0160-Scr

Got it.

What’s next

Many more things can be done with types: assign different styles (Types maps to css classes), have different shapes in maps, different layouts, different toolbars, different dialogs. Types can be created to ease display, managing items but also to organize, classify knowledge. In fact all Kneaver is build like this, Kneaver is used to define itself.

We have seen how to call templates directly in individual items, than how to create a type and finally how to surcharge a template for this type. This all is done in a few clicks and is extremely powerful for formalizing even more your Knowledge. It is a practical approach to start to define everything as topics but when you are advanced you see the benefit of adding types related to your activity. That’s where you appreciate that Kneaver is extensible.