How to create post type

About PostType

Post types has been introduced in Tendoo to ease modules and themes development. It's not a new feature, since it's already used by WordPress. This may help developers to skip some hassles while creating UI.
Post Type is inspired by current WordPress Custom Post type, but is initialised by his way.
In this guide, we'll learn how to create Post Type, which is two differents classes connected together : Custom Query & Post Type.

How to initilize a Post Type and where to do it

PostType must be used only withing "ini.php" file (module a theme). It possible to use within "backend.php" but only for administration purposes.
The basic way to create a post type is to use "PostType" class as follows

<?php
// PostType class is include by default on Tendoo CMS
$CustomPost	=	new PostType( array(
		'namespace'	=>	'custom_post', // required
  	'label'			=>	__( 'Label' )
) );

$CustomPost->define_taxonomy( array(
  'is_hierarchical'	=>	true // or false
) );

$CustomPost->run(); // otherwise Post type won't be available

Creating post type as shown will create into Tendoo dashboard for this post type.

How to create meta field on post type

It's abolutely required for you to know how to handle GUI V1 for tendoo CMS.
Creatng fields for post type is easy with "event manager".
Here is how it's done.

<?php
// before running post type
function after_editor_plugin( $params )
{
  	$gui_object								=	riake( 0 , $params );
  	$posttype_object					=	riake( 1 , $params );
  	$current_meta_namespace		=	riake( 2 , $params );
  	$post											=	riake( 3 , $params ); // only provided while editing a post
  	$posttype_namespace				=	riake( 'namespace' , $posttype_object->get_config() );
  
  	// Apply code only for specific post
  	if( $posttype_namespace == 'posts' ) 
    {
      	$gui_object->set_item( array(
          	'type'	=>	'text',
            'name'	=>	'post_meta[custom]', // your meta should have this form "post_meta[your_meta_name_field]"
            'label'	=>	__( 'Custom Post' ),
            'value'	=>	riake( 'custom' , $post ) // here is how to refill field for edition mode. If your post meta name is "post_meta[my_meta]", then use riake( 'my_meta' , $post ); to fill the field.
        ) )->push_to( $current_meta_namespace ); // Current meta namespace is provided in order to the event name.
    }
}
bind_event( 'after_editor_inition' , 'after_editor_plugin' );

$CustomPost		=	new PostType( array( 'namespace' => 'custom' ) );
$CustomPost->run();

"$currentmeta_namespace" is the name of current meta according to the event name. If you are using "after_editor_inition" event, $current_meta name will have "editor" meta namespace.

If youre using "after_title_inition", $current_meta_name will have "title" meta box namespace, and so on.