Chunks for forms and control panels
PubKit uses template chunks for two kinds of administrative page: forms for input and tables of items with command links for overview and management.
Input forms are fairly standard HTML forms with the "item edit" page as their action attribute. Forms may be defined in normal MODx chunks, or can be files in the pubKit/chunks folder with names like chunk.news.html, specified in the snippet call as &formtpl=`@FILE:news`.
Management list templates usually require each item to be framed as a table row, with TD cells for data and commands such as:
- item's publication status and position in the list ("rank")
- item title, with either a hyperlink to the edit page with command=edit and docId=[+id+] in the query string, or a form with the data in hidden fields and Javascript to mimic the Submit button;
- a Delete command, either in a query string, naming the current page as returnId, or using a form;
- a command, setField or updateTv, to modify a document field or custom TV directly via URL query strings or forms. See the listing for news.manage.tpl to see how the setField command can be used to publish/unpublish an item directly from the management list, or a TV for an "archived" flag can be set or cleared directly from the list.
The PubKit E1.0 sample pages also demonstrate in the News Management page the use of jQuery to reduce the number of form elements needed, and to offer multiple-selection actions (e.g. archiving a whole bunch of items) in conjunction with a suitable snippet.
The example chunks often use Ditto, with PHx to format output strings for colour-coding or to present data selectively according to the item's status. The package includes custom PHx modifiers to assist this.