FoxSimpleTodoList

Summary: An example of how to use Fox to setup a simple 'todo list'.
Version: 2007-04-03a
Prerequisites: Fox
Status: Functional
Maintainer:
Categories: CMS PIM Fox

Questions answered by this recipe

How do I use Fox to setup a simple no frills "todo" style list?

As presented this recipe should leave you ending up with a todo list looking something like this:

*This is an example.2007.03.05 - 05:18#1 — Feral — delete
*This is another example.2007.03.05 - 05:19#2 — Feral — delete
Description:

Something like this anyway; It is a bulleted list with the description left aligned and the time/author/delete/etc rfloat aligned; Regardless, you can set it up to appear as you wish.

Description

(:An example of how to use Fox to setup a simple todo list.:)

You can use the excellent Fox form processor to setup a very simple but functional todo list with (optional) author recognition.

Note that the author recognition is totally optional and as presented requires the following in your config in someplace:

# add conditional markup: (:if authorid AUTHID:)
$Conditions['authorid'] = "\$GLOBALS['AuthId']==\$condparm";

All this does is add a new conditional that allows you to compare the currently logged in user's $AuthId. I prefer this to base author name, however that works just as well.

Fox allows many options on the placement of the added items, however for my uses I chose to place them on the same page as my input form both for ease of use and simplicity.

To do this we place the input form on the page you wish the todo list to be present on; Feel free to place this on any page, as long as you have edit rights, it does not matter which.

On the page of your choice add your form:

(:if auth edit:)
(:fox messageform template=Main.ToDoListEntryTemplate:)
(:input hidden postnr value='{{*$FullName}$FoxCountInc}':)
(:input hidden author value="{$AuthId}":)
(:table align=center:)
(:cell:)Description: (:input text description size=60:) (:input submit post Add:)
(:tableend:)
(:foxend messageform:)
(:ifend:)

An then add (:foxappend messageform:) on the line where you want your todo list items to show; They will be above this location (due to (:foxappend <formname> :)

Note, as presented the form will only show if the viewer has edit rights.

As presented we tell Fox to use a template page, Main.ToDoListEntryTemplate. The contents of this page are as follows:

#foxbegin#
*%rfloat%[-{$$(date Y.m.d - H:i)}-] &mdash; '''#{$$postnr}''' &mdash; {$$author}(:foxcount:)
(:if expr ( auth admin ) OR ( authorid {$$author} ) :) &mdash; {[foxdelrange]}(:if:)%%{$$description}
#foxend#

This is the format of each todo entry as they are entered into the page by Fox. This means that if you change this later the older entries will not reflect the change, however all subsequently added entries will.

As an example:

On my main index page:

!TODO
(:foxappend messageform:)
(:if auth edit:)
(:fox messageform template=Main.ToDoListEntryTemplate:)
(:input hidden postnr value='{{*$FullName}$FoxCountInc}':)
(:input hidden author value="{$AuthId}":)
(:table align=center:)
(:cell:)Description: (:input text description size=60:)(:input submit post Add:)
(:tableend:)
(:foxend messageform:)
>>>right<<<
[--[[Main.ToDoListEntryTemplate]]--]
>>><<<
(:ifend:)

The template: (Main.ToDoListEntryTemplate)

#foxbegin#
*%rfloat%[-{$$(date Y.m.d - H:i)}-] &mdash; '''#{$$postnr}''' &mdash; {$$author}(:foxcount:)
(:if expr ( auth admin ) OR ( authorid {$$author} ) :) &mdash; {[foxdelrange]}(:if:)%%{$$description}
#foxend#
Example: (on one line)
  • {$$(date Y.m.d - H:i)}#{$$postnr} >>>> >>>> — author — delete{$$description}

An alternative template:

#foxbegin#
(:table width=100% border=1:)
(:cell class=messageitem align=left:){$$description}
(:cell width=160px class=messagehead align=right:)
[-{$$(date Y.m.d - H:i)}-] {$$author} - (:foxcount:)
(:if expr ( auth admin ) OR ( authorid $author ) :){[foxdelrange]} - (:if:)'''#{$$postnr}''' 
(:tableend:)
#foxend#
Example:
{description} {$$(date Y.m.d - H:i)}

author - delete - #{$$postnr}

Note that the foxbegin and foxend markers are a requirement for the template, however they will not be present in the todo list as they are used by Fox to know what section of the template page to use.

comment: Fox will use all of the template. The markers are used by Fox to create range identities on the target page, which in turn are used by Fox's range delete, so the delete action knows what to delete, i.e. a specific range. - HansB

Notes

Release Notes

Year/month/day "release date" style.

  • 2007/03/05 - Feral - Initial

See Also

Contributors

  • Feral -- initial.
  • Special thanks to HansB for his work on Fox which makes this possible. (=

Comments

See discussion at FoxSimpleTodoList-Talk?

User notes +1: If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.