user-pic

How to use mt:If to compare two tag values

Vote 0 Votes

Please forgive me if this information is easily found somewhere. I've spent about half an hour using Google and this forum's search unsuccessfully, but you never know if you're missing something obvious.

I am trying to use mt:If to compare the values of two tags. (In my case, mt:CommentEmail and mt:EntryAuthorEmail. Since I am not using registration for my commenting, I want to evaluate whether the comment author is the author of the email by a simpler test.)

None of the examples on the mt:If documentation page use tag values, and I'm having a hard time tracking down any source that tells how to accomplish this.

http://www.movabletype.org/documentation/appendices/tags/if.html

Any help anyone can provide would be most helpful. Thanks!

Reported on Movable Type 4.2

3 Replies

| Add a Reply
  • After much searching I finally found out how to use mt:SetVarBlock to accomplish this. I've added a comment to the mt:If reference page in an attempt to help anyone else who may have this problem in the future.

    http://www.movabletype.org/documentation/appendices/tags/if.html#comment-19277

  • <mt:SetVar name="MyCommenterEmail" value="<$mt:CommentEmail$>">
    <mt:If name="OwnerEmail" eq="<$mt:EntryAuthorEmail$>">
            <!-- do something -->
    </mt:If>
    

    Example (based on default Comment Detail template: http://www.movabletype.org/default_templates/4.2/comment_detail.mtml):

    <mt:SetVar name="MyCommenterEmail" value="<$mt:CommentEmail$>">
    <div class="comment<mt:If name="OwnerEmail" eq="<$mt:EntryAuthorEmail$>"> YOUR_CSS_CLASS</mt:If>"<MTIfArchiveTypeEnabled archive_type="Individual"> id="comment-<$MTCommentID$>"</MTIfArchiveTypeEnabled>>
        <div class="inner">
            <div class="comment-header">
                <div class="asset-meta">
                    <span class="byline">By <span class="vcard author"><$MTCommentAuthorLink default_name="Anonymous" show_email="0"$></span><MTIfNonEmpty tag="CommentAuthorIdentity"><$MTCommentAuthorIdentity$></MTIfNonEmpty> on <a href="#comment-<$MTCommentID$>"><abbr class="published" title="<$MTCommentDate format_name="iso8601"$>"><$MTCommentDate$></abbr></a></span>
                </div>
            </div>
            <div class="comment-content">
                <$MTCommentBody$>
            </div>
        </div>
    </div>
    
  • Sorry, this code is true:

    <mt:SetVar name="MyCommenterEmail" value="<$mt:CommentEmail$>">
    <mt:If name="MyCommenterEmail" eq="<$mt:EntryAuthorEmail$>">
            <!-- do something -->
    </mt:If>
    
    <mt:SetVar name="MyCommenterEmail" value="<$mt:CommentEmail$>">
    <div class="comment<mt:If name="MyCommenterEmail" eq="<$mt:EntryAuthorEmail$>"> YOUR_CSS_CLASS</mt:If>"<MTIfArchiveTypeEnabled archive_type="Individual"> id="comment-<$MTCommentID$>"</MTIfArchiveTypeEnabled>>
        <div class="inner">
            <div class="comment-header">
                <div class="asset-meta">
                    <span class="byline">By <span class="vcard author"><$MTCommentAuthorLink default_name="Anonymous" show_email="0"$></span><MTIfNonEmpty tag="CommentAuthorIdentity"><$MTCommentAuthorIdentity$></MTIfNonEmpty> on <a href="#comment-<$MTCommentID$>"><abbr class="published" title="<$MTCommentDate format_name="iso8601"$>"><$MTCommentDate$></abbr></a></span>
                </div>
            </div>
            <div class="comment-content">
                <$MTCommentBody$>
            </div>
        </div>
    </div>
    

Add a Reply

If you need to share template code, replace all the "<" signs with "&lt;" or use this utility.

Forum Groups

1773 6162

Last Topic: Excluding categories from blog by kholechek on Feb 9, 2012

86 302

Last Topic: website entries by masoud on Oct 26, 2011

1429 5077

Last Topic: What apocalypse hit this community in the middle of 2011? by 75th on Feb 10, 2012

695 2910

Last Topic: Insert Image / File Fails by Russ Miller on Feb 10, 2012

84 291

Last Topic: How to have some other characters in entry basename automatically written by Afshin Haghighatnia on Dec 22, 2011

173 737

Last Topic: About the MT version stated in HTML source by Alex E. Schneider on Feb 7, 2012

190 567

Last Topic: Analytics Reporting by michael webster on Feb 5, 2012

48 210

Last Topic: An idea and also a request by Afshin Haghighatnia on Jun 29, 2011

64 246

Last Topic: jQuery in MT 5.1 still at 1.4 - why? by perlmonkey on May 25, 2011

code.sixapart.com

137 478

Last Topic: Getting a thumbnail with xpath by Peter on Mar 13, 2011

222 720

Last Topic: Custom Field for Asset Not Appearing by android on Feb 9, 2012