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.

the {if editable} conditional does not function properly

March 06, 2012 8:44pm

Subscribe [4]
  • #1 / Mar 06, 2012 8:44pm

    Jules van Schaijik

    210 posts

    At least, that’s what I think.

    I have the following code inside the exp:comment:entries tag

    {if editable}
     | <a href="#" class="edit_link">edit</a>
     <div class="editCommentBox">
     <textarea cols="70" rows="15">{comment_stripped}</textarea><br >
     <input type="submit" name="cancel" value="Cancel" class="cancel_edit">
     <input type="submit" name="save" value="Save" class="submit_edit">
     </div>
    {/if}

    The “Comment Edit Time Limit” is set to: 86400 seconds (24 hours)
    Can edit comments in their own channel entries? - set to NO
    Can edit comments in ANY channel entries? - set to NO

    I thought that given all of the above, a member from this group should be able to
    - see the edit link, and use it, for his own comments only
    - unless that comments is older than 24 hours.

    Instead, this member sees the edit link on all his comments, no matter how old they are, but none of the changes he makes are saved.
    He does not see the edit link under other people’s comments.

    Any idea what I am doing wrong?

    ——-

    In case it is helpful: I tested things with different Comment Administration settings, and these were the results:
    (All worked as it should, except where I added the *****. The edit link should not show up there at all.)

    Test Configuration A:
    Can edit comments in their own channel entries? - YES
    Can edit comments in ANY channel entries? - NO
    - Other member’s entry, but his own comment
      - edit link shows but does not save changes *****
    - Other member’s entry, but other people’s posts
      - no edit link
    - His own entry, his own comment
      - edit link shows and works properly
    - His own entry, but other people’s comments
      - edit link shows and works properly

    Test Configuration B:
    Can edit comments in their own channel entries? - YES
    Can edit comments in ANY channel entries? - NO
    - Other member’s entry, but his own comment
      - edit link shows and works properly
    - Other member’s entry, but other people’s comments
      - edit link shows and works properly
    - His own entry, his own comment
      - edit link shows and works properly
    - His own entry, but other people’s comments
      - edit link shows and works properly

  • #2 / Mar 06, 2012 11:13pm

    LMO

    203 posts

    After looking into the comments module it looks as if there is no check for the Edit Limit time when setting the ‘editable’ variable. So I believe you are doing nothing wrong, It just looks like it may have been missed.

    You can add some code to check for it but you would have to edit the core files.

     

  • #3 / Mar 07, 2012 8:21am

    Jules van Schaijik

    210 posts

    Hi VIM Interactive,

    Thanks for looking into this. Your response leaves me with two questions:

    1. Why can said member not save his edits at all?

    2. Can I use the query module for checking on the time limit, and, if so, in what database is it stored?  (And then I’ll have to figure our how to check whether the current_time is later than the comment_date + the time_limit.)

    Thanks again,
    Jules

  • #4 / Mar 08, 2012 6:46am

    Jules van Schaijik

    210 posts

    In case anyone else reading this is interested, here’s how I solved the problem:

    - First I set the Comment Edit Time Limit to “0”. This makes every comment someone makes editable indefinitely.
    - Then I downloaded the MX Calculator plugin. This enables me to subtract the comment_date from the current_time, to see how much time has passed.
    - Here is the code that hides the edit link after 24 hours for everyone except super-admins.

    {if editable}
    {exp:mx_calc expression="{current_time format="%U"}-{comment_date format="%U"}"}
    {if calc_result < "86400" OR logged_in_group_id == "1"}
     | <a href="#" class="edit_link">edit</a>
     <div class="editCommentBox">
     <textarea cols="70" rows="15">{comment_stripped}</textarea><br >
     <input type="submit" name="cancel" value="Cancel" class="cancel_edit">
     <input type="submit" name="save" value="Save" class="submit_edit">
     </div>
    {/if}
    {/exp:mx_calc}
    {/if}

    It would be much nicer, of course, if the Comment Edit Time Limit worked. Is that on someone’s bug list, or should I do something to add it?

  • #5 / Mar 08, 2012 10:53am

    Shane Eckert

    7174 posts

    Hello all,

    I am sorry to hear you are running into this problem.

    That is a very creative solution.

    Did your settings on the back end stay the same?

    I found this bug, but it’s the only one I could find related at all to comment timeouts on the front end. It sounds close to what you are describing, but not totally.

    The part of this that needed extra work to function was the comment timeout?

    Are these settings still exactly like this:
    The “Comment Edit Time Limit” is set to: 86400 seconds (24 hours)
    Can edit comments in their own channel entries? - set to NO
    Can edit comments in ANY channel entries? - set to NO

    What version are you currently on?

    I Am glad to see that it is working, but maybe we can get to the bottom of why it was not in the first place.

    -Shane

  • #6 / Mar 10, 2012 4:39pm

    Jules van Schaijik

    210 posts

    Hi Shane,

    I changed the Time Limit to “0”. For some reason, setting it to “86400” caused the member not to be able to edit his comments at all.

    So now my settings are as follows:

    The “Comment Edit Time Limit” - set to: 0
    Can edit comments in their own channel entries? - set to NO
    Can edit comments in ANY channel entries? - set to NO

    I am on version 2.4.0

  • #7 / Mar 12, 2012 12:35pm

    Shane Eckert

    7174 posts

    Hello Jules van Schaijik,

    I am glad that it is working now. I am making a note of this post and will bring it up with a Dev to try and better understand this.

    Is there anything else I can help with?

    Cheers,

  • #8 / Mar 12, 2012 1:40pm

    Jules van Schaijik

    210 posts

    I’m all set.  Thanks!

  • #9 / Mar 12, 2012 1:47pm

    Shane Eckert

    7174 posts

    Hey Jules van Schaijik,

    That’s awesome!

    Cheers,

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

ExpressionEngine News!

#eecms, #events, #releases