How to create an option page on Tendoo CMS

Leaving tendoo handle page option, is an easiest and quick way to create option page for your app.

This feature require you to enable GUI for your app. Please refer to creating UI with GUI on tendoo.

All fields created with GUI will be saved to tendoo options. You can set a namespace or save it as it stands. Each fields names will be directly retrievable while using "get_meta('key')", where field name is the key. It works if namespace isn't in care.

While using namespace, each key/value will been saved as sub array. And all options data will be retrievable using "get_meta('namespace')".

Here is an example (With namespace enabled).

<?php
// we assume GUI is already available at $this->gui
$this->gui->set_meta( array(
  'namespace'			=>	'custom_namespace',
  'title'					=>	__( 'Meta Title' ),
  'gui_saver'			=>	true,
  'use_namespace'	=>	true,
) )->push_to( 1 );

// adding a sample field

$this->gui->set_item( array(
  'type'					=>	'text',
  'name'					=>	'pseudo',
  'label'					=>	__( 'Enter your pseudo' )
) )->push_to( 'custom_namespace' );

$this->gui->set_item( array(
  'type'					=>	'password',
  'name'					=>	'password',
  'label'					=>	__( 'Enter your password' )
) )->push_to( 'custom_namespace' );

/**
 * Each meta box fields value will be saved under "custom_namespace" name.
**/

$my_options	=	get_meta( 'custom_namespace' );

// while using var_dump( $my_options ); will output something like this.

array(
  'pseudo'		=>	'',
  'password'	=>	''
);

Without namespace enabled

<?php
// we assume GUI is already available at $this->gui
$this->gui->set_meta( array(
  'namespace'			=>	'custom_namespace',
  'title'					=>	__( 'Meta Title' ),
  'gui_saver'			=>	true,
  'use_namespace'	=>	false,// it's not necessary since that's the default value.
) )->push_to( 1 );

// adding a sample field

$this->gui->set_item( array(
  'type'					=>	'text',
  'name'					=>	'pseudo',
  'label'					=>	__( 'Enter your pseudo' )
) )->push_to( 'custom_namespace' );

$this->gui->set_item( array(
  'type'					=>	'password',
  'name'					=>	'password',
  'label'					=>	__( 'Enter your password' )
) )->push_to( 'custom_namespace' );

/**
 * Each fields value will be saved separately.
**/

$pseudo	=	get_meta( 'pseudo' );
$password	=	get_meta( 'password' );