Does anyone know if it’s possible for the Multi-Text extension to display its rows in “reverse chronological order?” Currently, any rows you add, show up at the bottom of the column(s) (both in the edit page, as well as how it’s displayed on the final web pages). I’m wondering if it’s possible to display them in reverse? Making sense?
I’ve modified this extension previously to allow a parameter for reverse=”yes” and it performs an array_reverse() on it. I haven’t yet submitted it to Mark to add in, but if you’re php savvy, you could do the same. Or as the godfather of soul says, store it in an array, and reverse it up.
Luc,
Here’s code to do it if you had one column. For two columns, you can either format them correctly where $multiText is defined, or start looking into multi-dimensional arrays. Remember that PHP needs to be on output. I’m sure there’s a neater way to do this, but it’s late:
<?php
$multiText = '{multiTextField backspace="1"}{col_1}|{/multiTextField}';
$multiArray = explode('|',$multiText);
$multiArrayRev = array_reverse($multiArray);
foreach( $multiArrayRev as $value )
{
echo "$value";
}
?>
thanks Slapshot
I haven’t tried your code yet. A friend wrote a javascript hack that renders the displayed data in reverse order. It works perfectly, except – of course – in IE.
This hack is OK, but temporary. I think I’ll work on a method to add new text fields in the weblog-entry stage, rather than in the display stage. It would help a lot to have the option to add a field below (current default) or ABOVE the fields.
Here’s that javascript hack that ALMOST resolves this. The javascript sits at the bottom of my page, right after the final </html> tag. Anyone see a way to fix this? Here it is below (the ID’s “list1”,”list2”, etc.. listed in the array recall the ones assigned to each individual multi-text field nested within its own DIV):
var arrListset = Array("list1","list2","list3","list4","list5","list6");
for (l in arrListset) {
reverseUl(arrListset[l]);
}
function reverseUl(ulId) {
var tmpUlRev = "";
var tmpUl = document.getElementById(ulId)[removed];
if (tmpUl.indexOf("<li>") > -1) {
var arrUl = tmpUl.split("</li>");
arrUl.reverse();
for (n in arrUl) {
tmpUlRev = tmpUlRev + arrUl[n] + "</li>";
}
} else {
tmpUlRev = tmpUl;
}
document.getElementById(ulId)[removed] = tmpUlRev;
}
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.