Is there a getLastChangeDate() function for NewsArticles and Albums?

I have a custom theme that uses ZenPage and CombiNews. After I publish a NewsArticle or Album, I often make updates to it. In my NewsArticle list and my Album list, I would like to show the original publish date for each item as well as the date that each item was last updated. An example is found here:
`http://www.zenphoto.org/news/category/user-guide`

I found the getPageLastChangeDate() function for Pages, but I have not found anything analogous for NewsArticles, Albums, or Images. Is there a (easy) way to do this?

I've written my own theme, so I'm not afraid of code, just lazy. <grin>

Comments

  • acrylian Administrator, Developer
    1. Articles yes. There is no function though, you have to use the object model to get the unformatted last change and then format the date fetched. See the code of `getPageLastChangeDate()`. Those page functions actually are just kept for backward compatibility and probably become deprecated some time.

    2. Albums no. No function but you could use standard PHP file system functions to get such a date.
  • Just a warnin on the album/image dates from the filesystem. On Unix systems there is no concept of a "creation" date and the last modified date can be updated for reasons that you might not expect.
  • For anybody else interested here is how I did it:

    In my next_news() loop and news article display:
    `
    if (getNewsType() == "news") {
    global $_zp_current_zenpage_news;
    $d = $_zp_current_zenpage_news->get("lastchange");
    echo ", last edit: ".zpFormattedDate(DATE_FORMAT,strtotime($d));
    }
    `
    In my pages display:
    `
    echo ", last edit: ";
    printPageLastChangeDate();
    `
    I guess I don't need to show a last edit date for albums/pictures (since the info is not there). If I figure out how to submit a change request, I will ask that update date for an album and picture be supported as well.
  • acrylian Administrator, Developer
    Yep, that's the way to do it. `$_zp_current_zenpage_news->getLastChange()` is also possible btw.

    As my colleague the change date is complicated for albums and images itself. If you mean changes to the title, description or similar that would work the same like with articles or pages. But that is not usually what you mean for a last change on those I guess.
  • Acrylian: Your last comment shows me that I was not clear in what I wanted for albums and images.

    Actually, I do want to use the last change date for the Album/Image title/description as the last change date for the Album/Image and display that. Oh, and if an image is added to an album, that would update the last change date for the album as well.

    I am not interested in displaying a change date for the actual photo, the album thumbnail, the image metadata.

    I tried `get("lastchange")` for albums and it always returned the same value (Linux epoch beginning maybe?) which suggested to me that maybe the value was there but just not set. Or it could be that's what the format functions do with FALSE as input. I didn't pursue it.

    Side note: I see I just moved from "Junior" to "Member". Ye-Haw! When do I get to learn the secret handshake?
  • <excitement>
    While reviewing the my ZP admin page, I noticed the Database quick reference. I looked into the table definition for albums and saw "updateddate". Could this be what I want? Can I do a `get("updateddate")` from the current album?
    <\excitement>
    Darn. No time to try it until tomorrow.
  • acrylian Administrator, Developer
    Yes, as my colleague said unix which the most servers use has no concept for this. You can access any database field that way. The date may not be populated for all albums. I don't remember the details but I think the value is taken from the latest image uploaded.
Sign In or Register to comment.