Not a developer? Go to MovableType.com

Documentation

IfEntryRecommended

Warning: This tag is not recommended as the implementation requires inline javascript which dramatically slows down the rendering of the html page in a browser. This tag is not currently used in any of the default template sets shipped with Movable Type.

Returns true if the entry has a score of more than zero in the community_pack_recommend namespace as defined in the Community Pack, false otherwise.

This mtml tag renders a block of javascript and two divs for true and false, respectively.

This is a custom tag in the Community Pack.

Examples

When used in the context of an entry or page:

This entry has
<mt:IfEntryRecommended>
    been recommended.
<mt:Else>
    not been recommended.
</mt:IfEntryRecommended>

The following javascript and html will be output:

This entry has
<script type="text/javascript">
    function scoredby_script_vote(id) {
        var xh = getXmlHttp();  
        if (!xh) return false;  
        xh.open('POST', 'http://sweetness.local/cgi-bin/branch-slapshot/mt-cp.cgi', true);  
        xh.onreadystatechange = function() {  
            if ( xh.readyState == 4 ) {  
                if (xh.status && ( xh.status != 200 ) ) {  
                    // error - ignore  
                } else {  
                    eval( xh.responseText );  
                }  
             }  
       };  
       xh.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' );  
       xh.send( '__mode=vote&id=' + id + '&blog_id=9&f=scored,sum&jsonp=scoredby_script_callback' );  
    }
    function scoredby_script_callback(scores_hash) {
        var true_block = getByID('scored_' + 2062);
        var false_block = getByID('scored_' + 2062 + '_else');
        var span;
        if (scores_hash['2062'] && scores_hash['2062'].scored) {
            span = getByID('cp_total_' + 2062);
            if (true_block)
                true_block.style.display = '';
            if (false_block) 
                false_block.style.display = 'none';
        }
        else {
            span = getByID('cp_total_' + 2062 + '_else');
            if (true_block)
                true_block.style.display = 'none';
            if (false_block) 
                false_block.style.display = '';
        }
        if (span) {
            if (scores_hash['2062'] && scores_hash['2062'].sum)
                span.innerHTML = scores_hash['2062'].sum;
            else
                span.innerHTML = 0;
        }
    }
</script>
<div id="scored_2062" class="scored" style="display:none">
    been recommended.
</div>
<div id="scored_2062_else" class="scored-else" style="display:none">
    not been recommended.
</div>
<script type="text/javascript" src="http://sweetness.local/cgi-bin/branch-slapshot/mt-cp.cgi?__mode=score&blog_id=9&id=2062&f=scored,sum&jsonp=scoredby_script_callback"></script>

Warning: The following javascript needs to be added (in one of the included javascript files or in the html head) for the mt:IfEntryRecommended to work:

function getByID(n, d) {
    if (!d) d = document;
    if (d.getElementById)
        return d.getElementById(n);
    else if (d.all)
        return d.all[n];
}
Back

Leave a Comment