9. Easy ACP Coding with qAdmin

qAdmin is a special feature from qE to allow rapid ACP development. It has most features you may need to create a database oriented script for ACP.

Usage

There are so many configurable option for qAdmin, please read the information in /admin/qadmin_demo.php for more detailed explanation for each configuration.

qAdmin needs two (or three) arrays to work:

  1. Data definition (list of table fields, with its definition such as field name, display title field type, etc).
  2. Configuration array.
  3. Title array (optional).

Data Definition

Data definition is an array of table fields definition, for example (from /admin/news.php):

// news_id :: int :: 10
$qadmin_def['news_id']['title'] = 'News Id';
$qadmin_def['news_id']['field'] = 'news_id';
$qadmin_def['news_id']['type'] = 'echo';
$qadmin_def['news_id']['value'] = 'sql';

// news_hit :: int :: 10
$qadmin_def['news_hit']['title'] = 'Hits';
$qadmin_def['news_hit']['field'] = 'news_hit';
$qadmin_def['news_hit']['type'] = 'echo';
$qadmin_def['news_hit']['value'] = 'sql';

It simply define each field used in the script according to the table used. The easiest way to build this very long array, is to use qadmin_build(table_name) function. For example:

qadmin_build ($db_prefix.'news');

The script will then create the data definition, which you can copy & paste it to your script, and tweak it if necessary.

Configuration Array

This array contains all configuration values for qAdmin, including table used, primary_key name, template used, etc. For example (from /admin/news.php):

$qadmin_cfg['table'] = $db_prefix.'news';	// table name
$qadmin_cfg['primary_key'] = 'news_id'; // table's primary key
$qadmin_cfg['primary_val'] = 'dummy'; // primary key value
$qadmin_cfg['template'] = 'default'; // template to use
$qadmin_cfg['fastsearch'] = 'news'; // fast search ID
$qadmin_cfg['auto_recache'] = true; // rebuild cache

Title Array

This array is optional. You can use this array to display additional information, eg, telling the user that he/she is now editing a News (and not a Page). For example (from /admin/news.php):

$qadmin_title['new'] = 'Add News';
$qadmin_title['update'] = 'Update News';
$qadmin_title['search'] = 'Search News';
$qadmin_title['list'] = 'News List';

You Are Done!

That's all! You are now ready to use qAdmin to manage your (ie) news. Simply call the qAdmin:

qadmin_manage ($qadmin_def, $qadmin_cfg, $qadmin_title);

And voila, the script is now ready to accept new item, or to update a saved item, or to search for certain item, or to list all saved items! No more coding! In fact, most of qE's ACP scripts are using qAdmin. That's why it looks cool & awesome.

Notes

  1. qAdmin only works for one (1) table. If you are using multiple table for a script, you need to create the script manually.
  2. qAdmin doesn't use external tpl. It only needs /skins/_admin/qadmin_section.tpl & /skins/_admin/qadmin_ezf_section.tpl. You can change the template used by modifying the configuration value.
  3. If you need additional steps after saving the value (eg, sending an email, etc); you can also configure qAdmin to redirect to a certain URL for futher processing. Please consult the qadmin_demo.php for more information.

There is no comment. Why not be the first?

More Comments/Post Your Own

Advertisement

Online Users

There are 4 users online.

Connect

Connect with us on Facebook

Newsletter

Subscribe to our newsletter for the latest updates and exciting promotions!