Was this page helpful?

Finding pages that define a tag

    Table of contents
    1. 1. Script Source
    2. 2. Script in Action

    This script shows how to find the page that defines tag (e.g. language:dekiscript).  The script uses the wiki.getsearch function to find at most one page that is tagged with the sought tag.  Once found, it checks if the tag is linked to a definition page.  If so, it emits a link with a description, otherwise it shows text describing that a page could not be found.

    Script Source

    {{
    var tag = "language:dekiscript"; 
    var found = wiki.getsearch("tag:" .. tag, 1, _, "type:wiki" ); 
    if(#found) { 
        var def = found[0].tags[tag].definition; 
        if(def) web.link(def.uri, "Tag definition at " .. def.path); else "(no definition for '".. tag .."')";
    } else "(no page found)";
    }}
    

    Script in Action

    (no definition for 'language:dekiscript')
    Was this page helpful?
    Tag page
    You must login to post a comment.

    Copyright © 2011 MindTouch, Inc. Powered by