Variable-Length Line Item Edits: Difference between revisions
Jump to navigation
Jump to search
(→PHP) |
|||
| Line 2: | Line 2: | ||
Describes how to add modules to CMS edit pages where variable-length arrays of objects can be added to a content record. | Describes how to add modules to CMS edit pages where variable-length arrays of objects can be added to a content record. | ||
= | =Markup= | ||
==Edit form== | ==Edit form== | ||
| Line 34: | Line 34: | ||
</div> | </div> | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=Examples= | =Examples= | ||
* [http://luzern.dbarchowsky.com/hostmgr/advice/edit.php Luzern Labs Advice CMS ] | * [http://luzern.dbarchowsky.com/hostmgr/advice/edit.php Luzern Labs Advice CMS ] | ||
Revision as of 17:59, 28 July 2012
Overview
Describes how to add modules to CMS edit pages where variable-length arrays of objects can be added to a content record.
Markup
Edit form
Simple include directive to insert entire module into the edit form.
include (SECTION_BASE_DIR."_templates/forms/[CONTENT_DESCRIPTION]_container.php");
Module container include
- Header followed by an
anchororbuttonelement to be used as button to add new line items. - Error container for AJAX errors specific to this module.
div element to serve as container for the line items.class="form-section"to contain the listings and control their position within the flow of the page.- And addition attribute to be used to reference the container and update its contents. E.g.
class="related-products"
- Test for array of line item objects and test for its size.
- Iteration through array, inserting static content for each existing line item along with buttons to edit and delete the line items, depending on the circumstances.
<div class="line-item-module">
<h3>[CONTENT_LABEL] <button class="add-[CONTENT_CODE]-btn" title="add [CONTENT_LABEL]">add [CONTENT_LABEL]</button></h3>
<div id="[CONTENT_CODE]-error-container" class="error"><!-- --></div>
<div class="form-section [CONTENT_CODE]-container">
<?
if (isset($input->[CONTENT_CODE]_array) && is_array($input->[CONTENT_CODE]_array) && count($input->[CONTENT_CODE]_array)>0):
foreach ($input->[CONTENT_CODE]_array as &$rp):
include (CONTENT_BASE_DIR."_templates/forms/[CONTENT_CODE]_line.php");
endforeach;
else: ?>
<div class="no-results"><i>No [CONTENT_LABEL] have been added.</i></div>
<? endif; ?>
</div>
</div>Examples