You are here: TCAO » Tag » RenderTag

Function: RenderTag

Documentation

Parameters

Css

Implementation

Primary INCLUDE

Parameters:
  • SOURCE - source topic
%STARTINCLUDE%<noautolink>
%ADDTOZONE{"head" topic="%WEB%.%TOPIC%" section="tagstyles"}%
%JQREQUIRE{"form"}%
%ADDTOZONE{"body" topic="%WEB%.%TOPIC%" section="tagsjs" requires="JQUERYPLUGIN::FORM"}%
<div id='tagBox' style='margin-top:-10px;margin-bottom:5px;'>
%INCLUDE{"%WEB%.%TOPIC%" section="tagbox"}%
</div></noautolink>
%STOPINCLUDE%

Tag Box

%STARTSECTION{"tagbox"}%Tags: <span id='tagList'>%INCLUDE{"%WEB%.%TOPIC%" section="taglist" REF="%BASETOPIC%" REFWEB="%BASEWEB%"}%</span> -
~~~  
%TWISTY{id="tagFormTwist" mode="span" showlink="Add Tag" hidelink="Cancel"}%
<div class='foswikiFormSteps'>
<div class='foswikiFormStep foswikiFormFirst foswikiFormLast'>
<form id='addTag' action='%SCRIPTURL{"save"}%/%WEB%/' method='post'>
<input type='hidden' name='topic' value='TagIdAUTOINC100001' />
<input type='hidden' name='templatetopic' value='%WEB%.TagTemplate' />
<input type='hidden' name='formtemplate' value='%WEB%.TagForm' />
<input type='hidden' name='editpermission' value='%WIKIUSERNAME%, %USERSWEB%.JointCommissionStaffGroup' />
<input type='hidden' name='TopicType' value='Tag' />
<input type='hidden' name='Status' value='Active' />
<input type='hidden' name='redirectto' value='%BASEWEB%.%BASETOPIC%' />
<input type='hidden' name='Reference' value='%BASEWEB%.%BASETOPIC%' />
*Tag to add:* <input id='tagField' type='text' size='40' name='Tags'> <input type='submit' value=' Add Tag '></form>
*Use an existing tag:* <br />
%TAGCLOUD{"%SEARCH{"TopicType = 'Tag' AND Status = 'Active'" 
  type="query"
  nonoise="on"
  web="%WEB%"
  format="$formfield(Tags)"
  separator=", "
}%"
  header="<div id='tagCloud' style='text-align:center; padding:15px;line-height:180%'>"
  format="<span style=\"font-size:$weightpx;line-height:90%\"><a href=\"#\" style=\"color:$fadeRGB(104,144,184,0,102,255);text-decoration:none\" title=\"Add tag\">$term</a></span>"
  footer="</div>"
  split=", "
  sort="alpha"
  buckets="40"
  exclude="%CALC{"$LISTJOIN(|,$GET(alltags))"}%"
  offset="12"
  lowercase="on"
  plural="on"
  map="bucket=pail"
  sep=" - "
  filter="off"
}%</div></div>
%ENDTWISTY%%ENDSECTION{"tagbox"}%

Tag List

%STARTSECTION{"taglist"}%%FORMATLIST{"%CALC{"$SET(alltags, $LOWER(%SEARCH{"TopicType = 'Tag' AND Reference = '%REFWEB%.%REF%' AND Status = 'Active'"
  type="query"
  web="%WEB%"
  nonoise="on"
  format="$formfield(Tags)"
  separator=", "
}%))$GET(alltags)"}%"
  split=", "
  unique="on"
  header=""
  format="<a href='$percntSCRIPTURL{view}$percnt/%REFWEB%/TagSearch?tag=$1' title='Show solutions with tag  &quot;$1&quot;.'>$1</a>"
  separator=" "
}%%ENDSECTION{"taglist"}%

Styles for Tags

%STARTSECTION{"tagstyles"}%
<style type='text/css'>
#tagActions {
}
</style>
%ENDSECTION{"tagstyles"}%

Javascript for Tags

%STARTSECTION{"tagsjs"}%
<script type="text/javascript" >
function useTag(theTag)  { 
  var current_value = $("#tagField").val();
  var new_value = current_value + ", " + theTag;
  $("#tagField").val(new_value);
  return false;
}
// post-submit callback 
function updateTags()  { 
  var retrievedKey = $( xhr.responseText ).find("#addTag>input[name=validation_key]").attr("value");
  $("#tagList").load("%SCRIPTURLPATH{"rest"}%/RenderPlugin/tag?name=INCLUDE;param=%WEB%.%TOPIC%;section=taglist;REF=%BASETOPIC%;REFWEB=%BASEWEB%");
  $('#tagField').attr('value','');
  $("input[name=validation_key]").attr( "value", retrievedKey );
  $('#tagFormTwist2hide a').click();
}
$(document).ready(function() { 
    var options = { 
        success: updateTags  // post-submit callback 
    };  
    $("#tagCloud a").click( function () {
      var theTag = $(this).text();
      useTag(theTag);
      return false;
    });
    // bind to the form's submit event - disabled for now
//    $("#addTag").submit(function() { 
        // inside event callbacks 'this' is the DOM element so we first 
        // wrap it in a jQuery object and then invoke ajaxSubmit 
//        $(this).ajaxSubmit(options); 
        // !!! Important !!! 
        // always return false to prevent standard browser submit and page navigation 
//        return false; 
//    });
}); 
</script>
</noautolink>
%ENDSECTION{"tagsjs"}%

Tag Form

%STARTSECTION{"tagform"}%%ADDTOZONE{"script" topic="%WEB%.%TOPIC%" section="tagsjs" requires="JQUERYPLUGIN::FORM"}%
%RENDERFOREDIT{topic="%SOURCE%" 
   header="<div class='foswikiForm foswikiEditForm'> 
         <h3>Topic data</h3> 
         <table class='foswikiFormTable' summary='Topic data'> $n<tbody>" 
   footer=" $n</tbody></table></div>" 
   format="<tr><th style='vertical-align:top;'><span title='$description'>$title</span></th><td align='left'>$edit</td></tr>" 
   separator=" $n" 
   exclude="TopicType|SubjectArea" 
   Tags_format="<tr><th style='vertical-align:top;'><span title='$description'>$title</span></th><td align='left'><input type='text' id='tagField' name='$name' class='foswikiInputField' size='50' value='%URLPARAM{"Tags" default="$value"}%' > <br /> <i>Use an existing tag: (click to select)</i> <br />$percntINCLUDE{\"%WEB%.%TOPIC%\" section=\"tagcloud\"}$percnt</td></tr>" 
   Tags_value="%IF{"'%BASEWEB%.%BASETOPIC%'/Tags!=''" then="%FORMFIELD{"Tags" topic="%BASEWEB%.%BASETOPIC%"}%" else="%CALC{"$LISTMAP($LOWER($PROPERSPACE($SUBSTRING($item, $EVAL($SEARCH([\./],$item) + 1), 50 ))),%FORMFIELD{"SubjectArea" topic="%BASEWEB%.%BASETOPIC%"}%)"}%"}%" 
}%
%ENDSECTION{"tagform"}%

Tag Cloud

%STARTSECTION{"tagcloud"}% 
%TAGCLOUD{"%DBCALL{"%WEB%.%TOPIC%" section="subjectSearch"}%" 
  header="<div id='tagCloud' style='text-align:center; padding:15px;line-height:180%'>"
  format="<span style=\"font-size:$weightpx;line-height:90%\"><a href=\"#\" style=\"color:$fadeRGB(104,144,184,0,102,255);text-decoration:none\" title=\"Add tag\">$term</a></span>"
  footer="</div>"
  split=", "
  sort="alpha"
  buckets="40"
  offset="12"
  lowercase="on"
  plural="on"
  map="bucket=pail"
  sep=" - "
  filter="off"
}%
%ENDSECTION{"tagcloud"}%

Converts Subject Areas to lowercase, spaced out, and removes any web references

%STARTSECTION{"subjectSearch"}%%SEARCH{"form.name ~ '*Form'" 
  type="query" 
  nonoise="on" 
  web="%BASEWEB%" 
  format="$percntCALC{\"$LISTMAP($LOWER($PROPERSPACE($SUBSTRING($dollaritem, $EVAL($SEARCH([\./],$dollaritem) + 1), 50 ))),$formfield(SubjectArea))\"}$percnt$percntIF{\"'$formfield(Tags)'!=''\" then=\", $formfield(Tags)\"}$percnt" 
  separator=", " 
}%%ENDSECTION{"subjectSearch"}%

This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Middle Fork Home Wiki? Send feedback
Syndicate this site RSS