On 30-07-2010 at 16:41:26 Richard Dyce <subscripti...@dyce.com> wrote:

At present, I'm using:

<th tal:repeat="item fields">
<a href="?criteria=${criteria}&amp;column=${repeat/item/key}" tal:content="repeat/item/key" >field name</a>

That looks ok.

where I've captured incoming values in the GET ...

$template->column = array_key_exists('column', $_GET)) ? htmlspecialchars($_GET['column']) : ''; # grab the sort column

Slightly off-topic, but usually you shouldn't use htmlspecialchars() when setting values for PHPTAL. PHPTAL HTML-escapes all output by default.

However, when you build URLs in TAL, you might need to urlencode() arguments.

I need to decide how to signify that a table, already sorted by 'column', should be reverse sorted by column. In the past I'd do this by using the case of 'column' - 'column' for ascending and 'COLUMN' for descending. Is there a way to do this without resorting to php? or is there a more idiomatic PHPTAL way of doing it?

One way is to handle such things outside PHPTAL, and just give it array of URLs for sorting.

If you want to compute those column names in TAL, you could write TALES modifier and use ${upper:criteria}, but I think there's nothing wrong with ${php:strtoupper(criteria)}.

Personally I use "column" and "-column" for sorting.

regards, Kornel

PHPTAL mailing list

Reply via email to