We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Can the "Multi-Text" extension display data in reverse chronological order?

Development and Programming

Luc Latulippe's avatar
Luc Latulippe
41 posts
17 years ago
Luc Latulippe's avatar Luc Latulippe

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?

       
james Brown's avatar
james Brown
492 posts
17 years ago
james Brown's avatar james Brown

im sure if you saved each element into a php array, you could. You would have to have php on output turned on though. but i haven’t seen a way to do this natively in the extension.

       
AJP's avatar
AJP
311 posts
17 years ago
AJP's avatar AJP

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 Latulippe's avatar
Luc Latulippe
41 posts
17 years ago
Luc Latulippe's avatar Luc Latulippe

Thanks AJP! Any chance you can share a snippet of that code here? My PHP kung fu ain’t that hot. I’m more of a cut-and-paste kinda guy.

       
AJP's avatar
AJP
311 posts
17 years ago
AJP's avatar AJP

I’ll see what I can do, but I can’t promise anything for a short time-table. Kinda swamped this day/week/month… Ughhhh…

       
Luc Latulippe's avatar
Luc Latulippe
41 posts
17 years ago
Luc Latulippe's avatar Luc Latulippe

Thanks AJP. I totally understand that situation! 😊

Anyone else out there?

       
Luc Latulippe's avatar
Luc Latulippe
41 posts
17 years ago
Luc Latulippe's avatar Luc Latulippe

Anyone else out there able to answer this one? Help!

       
Matt Weinberg's avatar
Matt Weinberg
489 posts
17 years ago
Matt Weinberg's avatar Matt Weinberg

Luc– how good is your PHP? If this were me I’d just throw the data into an array and do an array_reverse on it. Then output as you please.

       
Luc Latulippe's avatar
Luc Latulippe
41 posts
17 years ago
Luc Latulippe's avatar Luc Latulippe

hi Slapshot My PHP skillz are close to nil, otherwise I’d definitely do this myself. I was hoping someone else out there had already done this to this particular script and had met with some success doing it.

       
Matt Weinberg's avatar
Matt Weinberg
489 posts
17 years ago
Matt Weinberg's avatar Matt Weinberg

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";
      }

?>
       
Luc Latulippe's avatar
Luc Latulippe
41 posts
17 years ago
Luc Latulippe's avatar Luc Latulippe

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.

       
Luc Latulippe's avatar
Luc Latulippe
41 posts
17 years ago
Luc Latulippe's avatar Luc Latulippe

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;
    }
       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.