ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Problems/Unexpected behavior/results when using edit_date

January 17, 2012 3:52pm

Subscribe [2]
  • #1 / Jan 17, 2012 3:52pm

    bmschaaf

    171 posts

    A client wanted a simple page where they could see the last 25 EDITED entries and who had made the edit.

    Seemed simple enough.

    First, I need to get the channels and sort them correctly.

    I used this code:

    {exp:channel:entries limit="25" orderby=”edit_date” sort="desc" dynamic="off" status="open|closed|Featured" show_future_entries="yes" show_expired_entries="yes" sticky="no"}
           
         <li>
          <span class="date">{edit_date  format="%M %n, %Y - %g:%h %a"}  - {author}</span>
          {title}
    
         </li>
        {/exp:channel:entries}

    The results I get are not the same as I get when I run this MySQL command:

    SELECT * FROM `exp_channel_titles` ORDER BY edit_date DESC

    The MySQL command is correct, the channel:entries is wrong.

    UPDATE: Actually, they both look wrong to me.

    What constitutes an edit? Or, what kind of change updates the edit_date field?

    The second part to my problem is, how do I pull out the username of the last edit? I don’t see that in the same table. Thanks!

    Running v2.2.2 - Build: date 20110801

  • #2 / Jan 19, 2012 4:21pm

    bmschaaf

    171 posts

    No one wants to touch this one?

  • #3 / Jan 19, 2012 5:21pm

    Dan Decker

    7338 posts

    Hi Ben,

    Sorry we took a bit to get back to you, we were running our own tests. There are a few questions buried in this post and we wanted to catch them all for you. These are great questions by the way.

    During our testing, the MySQL command that you provided and the output from the channels tag resulted in the same results but not the same amount of information. For out test we added {ip_address} and were able to see that information. When you say that you get different results, do you mean that you get less information between the two methods or do you get a different amount of results returned and/or different information?

    The next question we tested out was to see what constitutes an edit. We found that a simple submission updates the “edit_date” field.

    The last question pertained to pulling the username. We were unable to do so, and upon further testing did not find any other way to pull that information into the results. The original author is the only one we get, which is the same result you came up with.

    I hope this helps, if you need clarification or have any more questions, please do not hesitate to ask.

    Thank you,

  • #4 / Jan 20, 2012 3:11pm

    bmschaaf

    171 posts

    Hi Ben,

    Sorry we took a bit to get back to you, we were running our own tests. There are a few questions buried in this post and we wanted to catch them all for you. These are great questions by the way.

    During our testing, the MySQL command that you provided and the output from the channels tag resulted in the same results but not the same amount of information. For out test we added {ip_address} and were able to see that information. When you say that you get different results, do you mean that you get less information between the two methods or do you get a different amount of results returned and/or different information?

    The next question we tested out was to see what constitutes an edit. We found that a simple submission updates the “edit_date” field.

    The last question pertained to pulling the username. We were unable to do so, and upon further testing did not find any other way to pull that information into the results. The original author is the only one we get, which is the same result you came up with.

    I hope this helps, if you need clarification or have any more questions, please do not hesitate to ask.

    Thank you,

    Ok, this was helpful.

    I think there was bug in 2.2.2 that was not updating the edit_date, as my edit_date was not changing as I made edits to entries. I have now updated to 2.3.1 and it now updates that field when I make a change.

    The update, however, didn’t fix everything. Edit_date still does not behave as you would expect.

    For example, in my code above, I am outputting the raw (unformatted) date and again using format=:

    {edit_date format="%M %n, %Y - %g:%h %a"} // {edit_date}

    However, this is what gets outputted:

    Jan 1, 2012 - 11:11 am // 20120120150855

    Those dates are NOT the same. Jan 20 is being formatted into Jan 1- that is very strange.

    Typo: I was outputting Month twice…sorting problem is real tho.

    Additionally, and not shockingly, when I try to sort by edit_date, I receive incorrect results. What does work is I run this MySQL command now:

    SELECT * FROM `exp_channel_titles` ORDER BY edit_date DESC

    Something fishy is going on with edit_date.

    Dan, are you able to replicate?

  • #5 / Jan 27, 2012 7:23pm

    Sean C. Smith

    3818 posts

    Hi Ben,

    I just tried this out on my 2.3.1 sandbox install. I edited an entry that was from a month ago and then used your code and it was sorted to the top of the queue as expected. Is there any add-ons installed that may be affecting the edit date in the database?

    SEan

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases