This module is rated as ready for general use. It has reached a mature form and is thought to be relatively bug-free and ready for use wherever appropriate. It is ready to mention on help pages and other OODA WIKI resources as an option for new users to learn. To reduce server load and bad output, it should be improved by sandbox testing rather than repeated trial-and-error editing.
{{#invoke:High-use|main|1=number of transclusions|2=discussion page, or use + notation|all-pages=|info=|demo=|form=|expiry=}}
number of transclusions: The first parameter is either a static number of times the template has been transcluded, or the word "risk" (without quotes) to display "a very large number of" instead of the actual value. This value will be ignored if transclusion data is available for the current page.
discussion page, or use + notation: The second parameter is overloaded. It will cause the number of transclusions to display as "#,###+" instead of "approximately #,###" when set equal to "yes" (without quotes). When used in this manner, values will be rounded down, instead of rounded to the nearest number with the appropriate number of significant figures. When set to any other non-blank value, it will replace the link to the template's talk page to the value of the parameter (for example, 2=WP:VPT will insert a link to WP:VPT),
|all-pages=yes: Will also output what percentage of all pages use the template. This should only be used for very highly transcluded templates, and the percentage will only display if its greater than 1%.
|info=extra information: When set to non-blank, will insert extra information into the template text if the template has more than 10,000 transclusions or parameter 1 is set to "risk".
|form=: When set to "editnotice", will display the message using {{editnotice}} instead of {{ombox}}.
|expiry=: Sets the |expiry= parameter for {{editnotice}}.
|system=in system messages: if set, this module looks like {{Used in system}}. Use that template directly as it performs some checks.
|fetch=: if set to false, the module will not attempt to fetch transclusion counts using Module:Transclusion count
Other functions
num
Produces the text and and link to toolforge surrounding the amount of transclusions.
risk
With this function, if risk is passed into the first unnamed parameter, or there are more than 100k transclusions, this will return risk.
text
Returns the body text of this template, with nil or a number of transclusions.
localp={}-- _fetch looks at the "demo" argument.local_fetch=require('Module:Transclusion_count').fetchlocalyesno=require('Module:Yesno')functionp.num(frame,count)ifcount==nilthenifyesno(frame.args['fetch'])==falsethenif(frame.args[1]or'')~=''thencount=tonumber(frame.args[1])endelsecount=_fetch(frame)endend-- Build output stringlocalreturn_value=""ifcount==nilthenifframe.args[1]=="risk"thenreturn_value="a very large number of"elsereturn_value="many"endelse-- Use 2 significant figures for smaller numbers and 3 for larger oneslocalsigfig=2ifcount>=100000thensigfig=3end-- Prepare to round to appropriate number of sigfigslocalf=math.floor(math.log10(count))-sigfig+1-- Round and insert "approximately" or "+" when appropriateif(frame.args[2]=="yes")or(mw.ustring.sub(frame.args[1],-1)=="+")then-- Round downreturn_value=string.format("%s+",mw.getContentLanguage():formatNum(math.floor((count/10^(f)))*(10^(f))))else-- Round to nearestreturn_value=string.format("approximately %s",mw.getContentLanguage():formatNum(math.floor((count/10^(f))+0.5)*(10^(f))))end-- Insert percentage of pages if that is likely to be >= 1% and when |no-percent= not set to yesifcountandcount>250000andnotyesno(frame:getParent().args['no-percent'])thenlocalpercent=math.floor(((count/frame:callParserFunction('NUMBEROFPAGES','R'))*100)+0.5)ifpercent>=1thenreturn_value=string.format("%s pages, or roughly %s%% of all",return_value,percent)endendendreturnreturn_valueend-- Actions if there is a large (greater than or equal to 100,000) transclusion countfunctionp.risk(frame)localreturn_value=""ifframe.args[1]=="risk"thenreturn_value="risk"elselocalcount=_fetch(frame)ifcountandcount>=100000thenreturn_value="risk"endendreturnreturn_valueendfunctionp.text(frame,count)-- Only show the information about how this template gets updated if someone-- is actually editing the page and maybe trying to update the count.localbot_text=(frame:preprocess("{{REVISIONID}}")=="")and"\n\n----\n'''Preview message''': Transclusion count updated automatically ([[Template:High-use/doc#Technical details|see documentation]])."or''ifcount==nilthenifyesno(frame.args['fetch'])==falsethenif(frame.args[1]or'')~=''thencount=tonumber(frame.args[1])endelsecount=_fetch(frame)endendlocaltitle=mw.title.getCurrentTitle()iftitle.subpageText=="doc"ortitle.subpageText=="sandbox"thentitle=title.basePageTitleendlocalsystemMessages=frame.args['system']ifframe.args['system']==''thensystemMessages=nilend-- This retrieves the project URL automatically to simplify localiation.localtemplateCount=('on [https://linkcount.toolforge.org/index.php?project=%s&page=%s %s pages]'):format(mw.title.getCurrentTitle():fullUrl():gsub('//(.-)/.*','%1'),mw.uri.encode(title.fullText),p.num(frame,count))localused_on_text="'''This "..(mw.title.getCurrentTitle().namespace==828and"Lua module"or"template")..' is used ';ifsystemMessagesthenused_on_text=used_on_text..systemMessages..((countandcount>2000)and("''', and "..templateCount)or("'''"))elseused_on_text=used_on_text..templateCount.."'''"endlocalsandbox_text=("%s's [[%s/sandbox|/sandbox]] or [[%s/testcases|/testcases]] subpages, or in your own [[%s]]. "):format((mw.title.getCurrentTitle().namespace==828and"module"or"template"),title.fullText,title.fullText,mw.title.getCurrentTitle().namespace==828and"Module:Sandbox|module sandbox"or"Wikipedia:User pages#SUB|user subpage")localinfoArg=frame.args["info"]~=""andframe.args["info"]if(systemMessagesorframe.args[1]=="risk"or(countandcount>=100000))thenlocalinfo=systemMessagesand'.<br/>Changes to it can cause immediate changes to the Wikipedia user interface.'or'.'ifinfoArgtheninfo=info.."<br />"..infoArgendsandbox_text=info..'<br /> To avoid major disruption'..(countandcount>=100000and' and server load'or'')..', any changes should be tested in the '..sandbox_text..'The tested changes can be added to this page in a single edit. 'elsesandbox_text=(infoArgand('.<br />'..infoArg..' C')or' and c')..'hanges may be widely noticed. Test changes in the '..sandbox_textendlocaldiscussion_text=systemMessagesand'Please discuss changes 'or'Consider discussing changes 'ifframe.args["2"]andframe.args["2"]~=""andframe.args["2"]~="yes"thendiscussion_text=string.format("%sat [[%s]]",discussion_text,frame.args["2"])elsediscussion_text=string.format("%son the [[%s|talk page]]",discussion_text,title.talkPageTitle.fullText)endreturnused_on_text..sandbox_text..discussion_text.." before implementing them."..bot_textendfunctionp.main(frame)localcount=nilifyesno(frame.args['fetch'])==falsethenif(frame.args[1]or'')~=''thencount=tonumber(frame.args[1])endelsecount=_fetch(frame)endlocalimage="[[File:Ambox warning yellow.svg|40px|alt=Warning|link=]]"localtype_param="style"localepilogue=''ifframe.args['system']andframe.args['system']~=''thenimage="[[File:Ambox important.svg|40px|alt=Warning|link=]]"type_param="content"localnocat=frame:getParent().args['nocat']orframe.args['nocat']localcategorise=(nocat==''ornotyesno(nocat))ifcategorisethenepilogue=frame:preprocess('{{Sandbox other||{{#switch:{{#invoke:Effective protection level|{{#switch:{{NAMESPACE}}|File=upload|#default=edit}}|{{FULLPAGENAME}}}}|sysop|templateeditor|interfaceadmin=|#default=[[Category:Pages used in system messages needing protection]]}}}}')endelseif(frame.args[1]=="risk"or(countandcount>=100000))thenimage="[[File:Ambox warning orange.svg|40px|alt=Warning|link=]]"type_param="content"endifframe.args["form"]=="editnotice"thenreturnframe:expandTemplate{title='editnotice',args={["image"]=image,["text"]=p.text(frame,count),["expiry"]=(frame.args["expiry"]or"")}}..epilogueelsereturnrequire('Module:Message box').main('ombox',{type=type_param,image=image,text=p.text(frame,count),expiry=(frame.args["expiry"]or"")})..epilogueendendreturnp