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.

Checking comment expiration date in channel entry

August 04, 2012 12:18am

Subscribe [2]
  • #1 / Aug 04, 2012 12:18am

    Coalescent

    48 posts

    Seems like a simple thing to do but I can’t figure it out:

    I have a summary page of blog posts, each of which has a ‘leave a comment’ link to the post’s detail page view where the comment form is. However, if the author of the post sets the Comment Expiration Date to some date and we roll past that date, I’d like to hide the ‘leave a comment’ link.

    So the question is, how can I check for that date in the looping channel entries tag? I know there is a ‘comments_expired’ conditional that can be used in the comment form tag pair but that doesn’t help me on the summary page.

    I cannot find any variable to check this from the actual entry. Surely there must be one…?!

    Thanks,
    Mike

  • #2 / Aug 04, 2012 9:57am

    John St-Amand

    865 posts

    Actually, I think you’re right, there isn’t one within the entries loop according to the docs - but I wonder if it might actually be there just the same.  In the Safecracker documentation, several examples actually use “comment_expiration_date” as a variable.  So perhaps there is one but it’s not listed as a variable in the channel entries loop docs.  I haven’t tried it, but if that rings true, then all you should have to do is a simple comparison between that variable and the current time variable.

  • #3 / Aug 04, 2012 9:59am

    John St-Amand

    865 posts

    Oh, and if that actually is a variable you can draw from, you may actually need to first do a check to see if it has a value before doing the conditional comparison.  Otherwise you could get unpredictable behaviour with a blank field being compared to current_time.

  • #4 / Aug 04, 2012 12:09pm

    Coalescent

    48 posts

    Thanks for the feedback John. We had tried that variable but got nothing back (it didn’t even parse). But we were applying a format parameter. I just tried it again without a format parameter and it seems to work - it looks like it spits out Unix time. Cool.

    Someone should probably update the User Guide with this.

  • #5 / Aug 05, 2012 9:01am

    John St-Amand

    865 posts

    Glad it helped, Coalescent.  And yes, I agree, the variable should at least be mentioned as available in the docs.  Curious that it doesn’t accept the format parameter.  At least you got it working!

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

ExpressionEngine News!

#eecms, #events, #releases