Manage sets of 'Event' items

Like the management overview for Posts, management of Events uses Ditto to list the items, with links to the relevant PubKit item-editing page. Additional data about the ID of the item and command to be applied is added either by adding a query string to the URL (GET), or by creating a mini-form for each item with the data in hidden INPUT fields (POST). You can use Javascript to simulate hyperlinks for the Submit action in the forms.

The Ditto template chunk for each item given below again uses the SetField and UpdateTv commands. See the page on managing Posts for details.

Here's the content of a Manage Events Items page, from a real site, not the demo package (wslArchived is a checkbox TV for flagging archived items):

<form method="post" action="event-edit" id="addItem">
<input type="submit" value="Add item" />
</form>

<div>
<table>
<thead><tr>
<th colspan="2">Item &amp; status</th><th>Date</th><th>To</th><th>Publish</th></tr>
</thead>

<tbody>
[!Ditto?parents=`7` &tpl=`events.manage.tpl` &showPublishedOnly=`0` &orderBy=`pkDate ASC,menuindex ASC` &extenders=`pkStatus` &filter=`wslArchived,0,1` !]
</tbody>
</table>
</div>

Here is the Ditto template chunk events.manage.tpl (the PHx modifiers that format status indicators and display dates conditionally are listed on another page. The hidden field "getter" makes Ditto retrieve the unpub_date field, so it can be used by PHx). Note you can also use jQuery to reduce the number of form elements, as shown earlier.

<tr>
<td class="flagColumn [+status:statusFormat=`flag`+]">[+status+]</td>
<td title="[+longtitle+]">
<form name="edit_[+id+]" action="event-edit" method="post">
<input type="hidden" name="docId" value="[+id+]" />
<input type="hidden" name="returnId" value = "[*id*]" />
<input type="hidden" name="preview" value="[+pkPreviewFlag+]" />
<input type="hidden" name="command" value="edit" />
<input type="hidden" name="getter" value="[+unpub_date+]" />

<a href="javascript:document.edit_[+id+].submit();">[+pagetitle:limit=`32`+]</a>
</form></td>

<td class="dateColumn [+status:statusFormat=`start`+]">[+pkDate:date=`%d-%m-%y`+]</td>
<td class="dateColumn [+status:statusFormat=`end`+]">[+pkDateTo:dateIfSet=`%d-%m-%y`+]</td>
<td class="dateColumn [+status:statusFormat=`pub`+]">[+pub_date:dateIfSet=`%d-%m-%y`+]</td>

<td><form name="del_[+id+]" action="event-edit" method="post">
<input type="hidden" name="docId" value = "[+id+]" />
<input type="hidden" name="returnId" value = "[*id*]" />
<input type="hidden" name="command" value = "delete" />
<a href="javascript:document.del_[+id+].submit();">Del</a></form></td>

<td><form name="arc_[+id+]" action="event-edit" method="post">
<input type="hidden" name="docId" value = "[+id+]" />
<input type="hidden" name="returnId" value = "[*id*]" />
<input type="hidden" name="command" value = "updateTv" />
<input type="hidden" name="tvName" value = "wslArchived" />
<input type="hidden" name="myValue" value="[+phx:if=`[+pkArchived+]`:is=`0`:then=`1`:else=`0`+]" />
<a href="javascript:document.arc_[+id+].submit();">
[+phx:if=`[+pkArchived+]`:is=`0`:then=`Arch`:else=`Unarch`+]
</a></form></td>

<td><form name="showHide_[+id+]" action="event-edit" method="post">
<input type="hidden" name="docId" value = "[+id+]" />
<input type="hidden" name="returnId" value = "[*id*]" />
<input type="hidden" name="command" value = "setField" />
<input type="hidden" name="docField" value = "published" />
<input type="hidden" name="myValue" value = "[+phx:if=`[+published+]`:is=`0`:then=`1`:else=`0`+]" />
<a href="javascript:document.showHide_[+id+].submit();">
[+phx:if=`[+published+]`:is=`0`:then=`Pub`:else=`Unpub`+]
</a></form></td>
</tr>