Extension talk:Cite

From MediaWiki.org
Jump to: navigation, search
Start a new discussion


Thread titleRepliesLast modified
How to replace 1.1 1.2 with a b c in reference footnotes010:01, 17 February 2015
Reading variables from the page in Extension:CiteThisPage002:21, 17 February 2015
cite error014:30, 15 January 2015
Popups with references123:02, 29 December 2014
reflist114:47, 29 December 2014
LUA Error With Cite816:00, 24 November 2014
filling references with a template219:25, 20 October 2014
Update extension:cite111:37, 7 July 2014
move page 215:11, 31 March 2014
"Fatal error: Call to undefined function wfmessage()"619:06, 10 February 2014
Solution: Template in refs and refs in templates201:20, 20 November 2013
Customizing009:05, 7 November 2013
the extension cannot run004:46, 12 October 2013
line height322:18, 28 July 2013
Allow defining references not used in page text?323:01, 27 June 2013
HTML5-style syntax?102:04, 10 May 2013
Cite does not create references907:23, 14 April 2013
Cite failing to render citations022:23, 12 April 2013
Number of references416:45, 7 March 2013
Mimic Wikipedia's Cite1218:43, 4 March 2013
First page
First page
Previous page
Previous page
Last page
Last page

How to replace 1.1 1.2 with a b c in reference footnotes


Can anywody please help to update 1.1, 1.2 number to a b c and ↑ to ^ in reference footnotes I tried this http://www.mediawiki.org/wiki/Extension:Cite#Set_references_to_use_.5E_and_letters_like_Wikipedia but still not working

Thanks, 17 February 2015

Reading variables from the page in Extension:CiteThisPage

A thread, Thread:Extension talk:Cite/Reading variables from the page in Extension:CiteThisPage, was moved from here to Extension talk:CiteThisPage. This move was made by Jdforrester (WMF) (talk | contribs) on 17 February 2015 at 02:21.

cite error

sometimes, a ref generates "cite error", e.g., when you use "name="xxx" with an empty ref, but there is no "real" ref with this name.

it would be useful to be able to find all pages with such errors.

mw contains a mechanism to track such things, called Special:TrackingCategories. there may be a better way to find all pages with cite errors - i'll be happy to learn.

if no such way exists, i suggest to track those through the special page meant for it.


קיפודנחש (talk)14:30, 15 January 2015

Popups with references

How do you make it so that references function as popups like on Wikipedia? You used to be able to do that with just the cite extension, but they took it away.

Xina78 (talk)16:16, 17 December 2014

if you mean enwiki when you say "like on wikipedia", it's done via gadget, namely en:MediaWiki:Gadget-ReferenceTooltips.js, which is explained in Reference Tooltips. there are some other options, specifically one lighter with less features: he:Mediawikiי:Gadget-CiteTooltip.


קיפודנחש (talk)23:00, 29 December 2014

I assume that the existing reflist has a <references /> baked into it. Otherwise, this update is going to break a lot of articles. I like <references /> and use it all the time when checking out a citation, but others simply use reflist.

Ancheta Wis (talk)14:52, 23 December 2014

What update?

Cavila (MW 1.22, MySQL 5.5.37-0, Php 5.4.4-14 squeeze, SMW 1.9.2, SF 2.7)14:47, 29 December 2014

LUA Error With Cite

I have copied the templates and the error occurs in the references section Lua error in Module:Citation/CS1 at line 2058: attempt to call method 'getTitle' (a nil value).

Backtrace: (tail call): ? Module:Citation/CS1:2058: in function "chunk" mw.lua:553: ? (tail call): ? [C]: in function "xpcall" MWServer.lua:73: in function "handleCall" MWServer.lua:266: in function "dispatch" MWServer.lua:33: in function "execute" mw_main.lua:7: in main chunk [C]: ?

not sure how to fix this would be appreciate it, if someone could help

RaneMstSage (talk)19:08, 11 April 2014

I have this problem too.

Billreid (talk)09:31, 2 May 2014

BTW, the script error Module:Authority_control:358: in function "chunk" also displays with identical discription of the full error in first post above.

Billreid (talk)11:43, 2 May 2014

I'm getting this problem too when using the Citation Template. Any potential fixes?, 14 May 2014

Me too. Any fixes?

Dnaslave (talk)18:06, 28 May 2014

I'm getting this error as well. See no help on google.

Vapblack (talk)15:13, 28 June 2014

Anyone found a solution to this?

A3vdMerwe (talk)08:56, 24 October 2014

Hi I had this problem. I 'solved' it by commenting out the section of code.

I edited the wiki page module:Authority_control.

I commented out the section called --Wikidata fallback if requested

   --Wikidata fallback if requested
   --[[    local item = mw.wikibase.getEntity()
    if item ~= nil and item.claims ~= nil then
      for _, params in pairs( conf ) do
          if params[3] ~= 0 then
              local val = parentArgs[params[1]]
              if not val or val ==  then
                       local canUseWikidata = nil
                   if reqs[params[1]] ~= nil then
                       canUseWikidata = matchesWikidataRequirements( item, reqs[params[1]] )
                       canUseWikidata = true
                   if canUseWikidata then
                       local wikidataIds = getIdsFromWikidata( item, 'p' .. params[3] )
                       if wikidataIds[1] then
                           parentArgs[params[1]] = wikidataIds[1]

Which basically just comments it out. It took a few minutes to work (caching?) but eventually got there. I'm not sure what other effects this will have.

2A00:1068:0:205:1137:E3A1:E067:393D17:18, 20 November 2014

That didn't come out correctly. Here is the correct version.

  --Wikidata fallback if requested
 --    local item = mw.wikibase.getEntity()
 --    if item ~= nil and item.claims ~= nil then
 --       for _, params in pairs( conf ) do
 --           if params[3] ~= 0 then
 --               local val = parentArgs[params[1]]
 --                      local canUseWikidata = nil
 --               if not val or val ==  then
 --                    if reqs[params[1]] ~= nil then
 --                        canUseWikidata = matchesWikidataRequirements( item, reqs[params[1]] )
 --                    else
 --                        canUseWikidata = true
 --                    end
 --                    if canUseWikidata then
 --                        local wikidataIds = getIdsFromWikidata( item, 'p' .. params[3] )
 --                        if wikidataIds[1] then
 --                           parentArgs[params[1]] = wikidataIds[1]
 --                       end
 --                    end
 --                end
 --            end
 --        end
 --    end
2A00:1068:0:205:9017:BBEB:3CDB:355A16:00, 24 November 2014

filling references with a template

Hello, within a template I have fields for filling the references, which look like this: <ref>Source: {{{Source Spanish|}}}</ref>. In the same template there is also the <references /> tag. Now, when using the template, I simply fill |Source Spanish=http://www.example.com. But under references, the URL won't show, it's only 1. ↑ Source: , without the template field value.

  • It's not related to the URL, any other text won't show either.
  • The position of <references /> is irrelevant, same outcome everywhere.

What am I missing?

Zabien (talk)18:55, 14 October 2014

i believe you should use the #tag: magic word if you want to use "ref" tag from inside a template.

see Help:Magic_words#Miscellaneous.

as to the "references" tag: it does not sound right to have this tag in the same template - this will place "references" once per each reference, instead of once for the whole page.

also, afair, if you use modern-enough version of the code, you can completely omit the "references" tag, to display the references at the end of the page. don't remember when was this introduced, and TBH, i am not 100% sure this is correct...


קיפודנחש (talk)21:50, 16 October 2014

Thank you very much! That hint did it! Works brilliantly with the #tag magic word and "ref". I do not yet see a problem with the <references /> tag, though. At the moment, the references passed via the form as well as manually added <ref>…</ref>s all neatly show up under references. I still need the tag to show them, I tried on 1.21.2 and 1.23.1 and it's demanded there. Not tried on 1.24 though.

Zabien (talk)19:25, 20 October 2014

Update extension:cite

Hi could we update Extension:cite please and move away from jquery.tooltip.js to jquery.ui.tooltip.js please because the author of jquery.tooltip recommends moving away from it because has not been updated since 2008 and he was the author of jquery.ui.tooltip.js., 5 July 2014

bug 67282 was created to address this issue.

[[kgh]] (talk)11:37, 7 July 2014

move page

hi I propose we move this page to extension:cite please. reson because extension cite page is the extension and we doint need to have cite.php extension page., 30 March 2014

Just because Cite.php is on a separate page does not mean that Extension:Cite needs to be expanded. What about Special:Cite.php?

[[kgh]] (talk)08:00, 31 March 2014

Oh ok but I thought that is included in extension:cite and is not a seperate extension., 31 March 2014

"Fatal error: Call to undefined function wfmessage()"

Fatal error: Call to undefined function wfmessage() in /home/wikimultiple/wikimultiple/extensions/Cite/Cite_body.php on line 1007

This happens on any page with citations. I am a rank beginner at these things. Could someone explain?

Astraea (talk)20:37, 2 September 2012

What version of MediaWiki do you use (check Special:Version), and where did you download the Cite extension exactly (what version).

Krinkle (talk)04:14, 3 September 2012

I got the same error. I'm using MW 1.16.2 and tried several snapshots of this extension, always the same error. This error can be fixed by replacing wfmessage() by wfMsg() but other errors appears after that.

Plalemand (talk)19:54, 17 January 2013

wfMessage() cannot be replaced by wfMsg(). wfMessage(), a global function referencing the Message class was introduced in MediaWiki 1.17. We strongly suggest you update to a supported version of MediaWiki or use an older version of Cite.

siebrand (talk)13:40, 18 January 2013

it would be nice to have somewhere a list of links to "sanctioned" versions of the extension per mediawiki version.

i guess it's enough to have links to specific git commits (just to demonstrate what i mean - something like this), because the gitweb/gerrit thingy already has a "snapshot" link that gets you the tarball ready to eat.


קיפודנחש (talk)21:45, 18 January 2013

How does one get an "older" version of cite? I want pre-Rel 19., 10 February 2014

don't know about "pre rel". here is a link to the rel-19 sources in source control. at the top of the page there are buttons for tarballs in various compression formats.



קיפודנחש (talk)19:06, 10 February 2014

Solution: Template in refs and refs in templates

This may be handy for others. I wanted to create a ref template to add a reference and a refs template to create the footer automatically unless there were no refs. Usage:

 per ref: {{ref|http://...|linktext}}
 footer: {{refs}}

The idea was to collect the references and set a variable refs which enables the footer. This requires Extension:ParserFunctions and Extension:Variables.

The following 2 templates - first attempt - did not work:

ref template:

<includeonly><ref>[{{{1}}} {{{2}}}]</ref>{{#vardefine:refs|1}}</includeonly>

refs template:

{{#if: {{#var:refs|}} | <span class="mw-headline"> <h2>References</h2> </span> <references /> }}

This fails because everything between the ref tags is collected until the references tag is called, and at this moment there are no more template arguments.

The following solution works - unfolded for better readability:

ref template:

[{{#var:link{{#var:i|0}}}} {{#var:text{{#var:i|0}}}}]

refs template:

{{#if:{{#var:refs|}} |  
<span class="mw-headline"> 
<references /> 

The ref template increments a variable i to define variables link0, text0, and on next call link1, text1, and sets the refs variable.
The part within the ref tags contains a second loop counter for i for the references invocation and expands the variables correctly.
The refs template just needs to reset the loop counter before the references tag is called.

This solution is template proof etc since the variables are defined at ref tag time.

Hope this is helpful for someone.

Hippie2000 (talk)02:28, 16 November 2013

Thanks, that sounds useful. I will give it a whirl.

Cavila (MW 1.19.7, MySQL 5.1.72-2, Php 5.3.3-7, SMW, SF 2.5.2)21:01, 18 November 2013

I noticed one side effect of this solution. URLs containing ?name=value don't pass as anonymous args. This is not specific to my solution but a side effect of passing anonymous template args.

In this case the reference is printed non clickable. What helps is numbering the arguments then:

Hippie2000 (talk)01:20, 20 November 2013


This is a very useful extension. But… I am not able to get the customization suggest on the main page (Set reference and reference number highlighting like Wikipedia). I followed the instructions (added the code to Common.css) but it is not working. The same with the suggestion here with line height code.

Emilio Speciale (talk)09:05, 7 November 2013

the extension cannot run

I already have the "extensions/Cite" directory, and the files are all no problem in the directory. But when I opened the "Special:Version" of my wiki, I found nothing listed in "Installed extensions".

I was also trying to add "require_once("$IP/extensions/Cite/Cite.php");" to the LocalSettings.php, but a 500 Internal Error happened.

My site's URL is


And my server provider is iPage.

Anyone could solve this problem? Thanks in advance!

Betoseha (talk)04:45, 12 October 2013

line height

I'm having a cosmetic / style problem with this application on my own wiki. I've noticed that the reference markers tend to mess with line height of the text. it's particularly a problem if the reference marker comes in the middle of a paragraph - the gap that the ref marker causes between that line of text and the line of text above it is comparable to the gap between normal paragraphs. This makes the text difficult to read, since it's hard discern where actual paragraph breaks are.

there has to be some kind of solution for this - I've noticed that reference markers don't alter the line height of the text at all in wikipedia, for example. any advice? I'm new to wiki platforms.

(if this needs to be somewhere else, please let me know - I just couldn't figure out where to go to ask for help), 28 July 2013

The usual trick is to use CSS to lower everything in superscript position (and/or possibly, to increase line spacing?). You could add something like the following to your CSS page (MediaWiki:Common.css or the css page of your user skin).

/* keep superscript and subscript text from breaking the line-spacing */
#bodyContent sup {
    font-size: smaller;
    vertical-align: baseline;
    position: relative;
    bottom: 0.33em;
#bodyContent sub {
    font-size: smaller;
    vertical-align: baseline;
    position: relative;
    bottom: -0.25em;;

See also [1]

Cavila (MW 1.19.7, MySQL 5.1.66, Php 5.3.3-7, SMW 1.8, SF 1.5.2}19:40, 28 July 2013

I'll try this out - thank you!, 28 July 2013
  • perfect* - this was driving me nuts, thanks so much!, 28 July 2013

Allow defining references not used in page text?

Edited by author.
Last edit: 04:48, 24 June 2013


Noone has responded to this question for months, so let me try rephrasing it without superfluous information:

Question: Is there a need in Ext:Cite to allow for adding references that would appear in the references list using <refereces/> or {{reflist}}, but without corresponding footnote marks inside the text?

I need this functionality in an extension I'm writing, and as I'm thinking of hacking my own local version of Cite to allow for it, I'm wondering if this can be of wider use. Original message below.

Thank you!

I have recently upgraded to MediaWiki 1.20 and noticed that an extension I wrote to keep track of bibliographies (Miranche/BiblioTex) was partly broken. The extension adds functionality to Extension:Cite to use BibTex bibliographic information, both provided in wiki text or stored on the local file system. The references are included in wiki text via <cite>...</cite> tags, which basically just unwrap into corresponding <ref>...</ref> tags. These parallel LaTeX usage, and accordingly I have also added <nocite>...</nocite> tags for references that I want to appear in the reference list but not in the text. Using a previous version of Ext:Cite, probably over 2 years old now, this worked no problem. Now, I get cite_error_references_missing_key.

The way I would deal with this locally would be to hack Ext:Cite to add an option, say $wgCiteAllowMissingKey, to allow for such references. I wanted to check, though,

  • Is there a relevant past discussion on why references in the text are now required?
  • Would an option to relax this requirement be useful in the public version of the Cite extension?

Thank you!

Miranche T C06:48, 26 February 2013

No replies for 4 months, replying to myself to bump the thread up.

Miranche T C04:46, 24 June 2013

it seems that your actual question is not really what you mean.

you asked "Is there a need in Ext:Cite to allow for adding references that would appear in the references list using <refereces/> or {{reflist}}, but without corresponding footnote marks inside the text?"

but it seems that what you really mean is not "is there a need" but rather "is it possible".

if the question is indeed "is there a need", then the answer (at least my answer) is "probably not".

if you ask "is it possible", i think the answer is still "probably not", but it should not be all that difficult to hack the extension to add "no cite mark" option, e.g. by adding a new attribute to the "ref" tag which will cause it to not display the link inside the text. (so some of the references will look like so: <ref nomark="true"> or somesuch) however, this requirement seems somewhat redundant: if you want to maintain a bibliographic list at the bottom of the page, why even use the "Cite" extension? you can just add such a list using standard wiki code, no?


קיפודנחש (talk)16:06, 24 June 2013

קיפודנחש, thanks for the reply.

Clarification: "if you want to maintain a bibliographic list at the bottom of the page, why even use the "Cite" extension?" Good question. Most of the refs in bibliographies I'm using are linked in the text, but not all. In other words, I want to be able to intersperse entries with refs in text and those without.

I know that this is possible in principle because it used to work a couple of years ago. The extension I wrote piggybacks on Cite -- it unwraps a <cite> tag into a <ref> tag in the text, and adds the ref given in <nocite> into Cite's internal list of refs without affecting the wiki text. All citations then used to show up in {{reflist}} in the order they were specified in original wiki text, with those supplied via <nocite> without back links. This worked fine with Cite as it was in late 2010/ early 2011, but is now impossible due to stricter error testing.

I'll go ahead & modify my copy of the extension so the syntax will work, and I'll try to do so via method overloading in derived classes so there's no intervention in Cite itself. On first inspection, though, this doesn't seem to be straightforward. My question is, then, if I end up changing Cite itself, would this functionality be useful in the larger world, whether through <ref nomark="true"> or similar syntax as you suggested, or through an API function that can be used in extensions, such as mine, that build upon Cite? I gather the answer to this is, probably not.

Peace, indeed.

Miranche T C20:16, 27 June 2013

HTML5-style syntax?

Cite.php syntax is not compatible with HTML5; this is an issue for consistently using HTML5 in MediaWiki – see mw:HTML5.

Cite.php uses XML-style syntax for “empty/void elements” – <ref name="foo" /> and <references /> – in a way that is not compatible with HTML5; the XML-style is from XHTML 1.0. This is not necessarily a problem per se, as these are Tag extensions, not actual HTML/XML tags, but as the web moves to HTML5, this will be a cause of inconsistency and confusion to users unless corrected. Further, it requires the MediaWiki software to support inconsistent syntax.

The easiest solution is probably to use templates to insulate users from the details of the tag syntax; this is detailed below.

§Issue[edit | edit source]

The issue is that in HTML5, the minimized tag sytax <foo/> is invalid for non-void elements, and is generally interpreted simply as a tag – <foo> – the trailing slash (/) is stripped, rather than interpreted as a terminator. As the Cite.php tags are non-void (they can have content), this is interpreted as a bare opening tag, without a closing tag.

Thus instead of XHTML <ref name="foo" /> and

<references />

in HTML5 one would need <ref name=foo></ref name=foo> and


(note that HTML5 allows unquoted attribute values).

Because the ref and references tags are very widely used (notably on English Wikipedia), this issue has very broad scope, even if the impact is minor.

§Background[edit | edit source]

The details are confusing; here is some background.

XML allows minimized tag syntax <foo/> for empty elements (see XML: Tags for Empty Elements and XHTML1: Empty elements). In XML, “empty element” means “has no content, whether or not element type declared with keyword EMPTY (meaning ‘cannot have content’)”, so it refers both to elements that cannot have content, such as <br> (usually serialized as <br/> where the slash is a terminator, but can be serialized as <br></br>) and elements that can have content, but do not, like an empty paragraph: <p></p>.

Per HTML5 “Elements” documentation: HTML5 “void element“ means “cannot have content”; it corresponds to XML’s EMPTY keyword. Further, trailing / are dropped (formally the slash is actually forbidden for non-void elements). This changes behavior for empty non-void elements. Void elements only have a single tag, where the / is optional, as in <br> though <br/> is also valid. Empty non-void elements, like empty paragraphs, need a closing tag (though this may be implied in some cases). For example, <p/> in HTML5 does not behave like <p></p> (an empty paragraph) as in XHTML, but it’s invalid syntax, and generally instead acts as bare opening tag: <p>.

§Proposal[edit | edit source]

The <ref name="foo" /> syntax is tricky, but the <references /> should be easy to handle. The use of the {{reflist}} template – which always (can?) output <references>...</references> – means that users are insulated from this. Further, <references></references> has the same behavior whether it has content or not: it includes any references in its content and lists pending inline refs.

The <ref name="foo" /> syntax is trickier because there are two behaviors for the <ref name="foo"> tag: create a new named ref (which is non-void), or refer to an existing ref (which is void, or handled by “if empty, then…”). At the tag level, clearer is to separate these, say by <ref name="foo">...</ref> followed by <ref2 name="foo"> to create and then refer to a named reference.

This would be easier if this issue were isolated from users via a template. At English Wikipedia {{ref}} is already used for a separate type of referencing, but {{fn}} (for “footnote”) is an almost unused template, so it could be used, and would be consistent with the {{sfn}} and {{efn}} template names. Using this, users could write {{fn|name=foo|...}} and then {{fn|name=foo}} later.

In more technical detail, the existing XML-style tags could be supported indefinitely, or deprecated then removed, with an automated migration tool. The tool would:

  • Replace <ref name="foo" /> by <ref2 name="foo"> (leave quotes as they are allowed) – or even by {{fn|name=foo}} and
  • Replace <references /> by <refererences></refererences> – or even by {{reflist}}

§Summary[edit | edit source]

In summary:

  • Authors should use templates: {{fn}} and {{reflist}}
  • Behind the scenes, add <ref2> tag and migrate existing usage.

How does this overall approach sound?

Nils von Barth (talk)10:30, 23 February 2013

I've already elaborated on HTML5#HTML in wikitext why HTML5 is irrelevant to stuff inside the Parser.

Daniel Friesen (Dantman) (talk)02:04, 10 May 2013

Cite does not create references

MediaWiki: 1.19.2
Snapshot of the Cite: for MediaWiki 1.19.x

So, I installed the Cite and added require_once to LocalSettings.php

Now I'm trying to repeat the example:
According to scientists, the Sun is pretty big.<ref>E. Miller, The Sun, (New York: Academic Press, 2005), 23-5.</ref>
The Moon, however, is not so big.<ref>R. Smith, "Size of the Moon", Scientific American, 46 (April 1978): 44-6.</ref>
== Notes ==
<references />

and I get the folowing:
According to scientists, the Sun is pretty big.<cite_reference_link>
The Moon, however, is not so big.<cite_reference_link>
<cite_references_prefix><cite_references_link_one> <cite_references_link_one><cite_references_suffix>

What's wrong?, 20 September 2012

Those snapshots are unreliable, as I experienced myself lately. Try downloading the extension through Git instead.

Cavila MW 1.17, MySQL 5.5.23, Php 5.3.10, SMW 1.7.122:06, 20 September 2012

Yeah, now I got the Cite extension by:

git clone https://gerrit.wikimedia.org/r/p/mediawiki/extensions/Cite.git

Replaced the previous one by that new one. But yet that has not changed anything, unfortinatelly. There are still <cite_reference_link> instead of footnotes.

Any further suggestions, please? I'm desperated with this extension, it didn't work that way since I had MediaWiki 1.17., 21 September 2012

Maybe a recent change messed things up? You can try older versions of the extension, also available through Git:

https://gerrit.wikimedia.org/r/gitweb?p=mediawiki/extensions/Cite.git;a=summary ("snapshot" gives you a download link)

Cavila MW 1.17, MySQL 5.5.23, Php 5.3.10, SMW 1.7.109:36, 21 September 2012

Nope, it didn't help too. I also tried snapshots of the Cite from 1.10 to the last 1.19 - none of them works correctly, all behave like I described.

Weird though - it actually does some work: translates <ref></ref> into <cite_reference_link>, but it seems that something messes with it.

I read somewhere, that some web-hosters have some "features" or "settings" on their servers, that prevents some extensions from working correctly. It seems that I'm the only one with such problem, and that means the problem is on my side, not on the extension's.

Abagnale OS Ubuntu 11.04; MW 1.19.2; MySQL 5.1.61; PHP 5.2.1711:25, 21 September 2012

OMG, I've found the reason - I guess, it's my stupidity.

I've read once again the Cite's page here and saw the text where it says about special names or I don't know how to name it. So, it's like I described earlier: I got some <cite_references_prefix><cite_references_link_one> <cite_references_link_one><cite_references_suffix> instead of references.

I simply went to the Wikipedia's special pages and copy source from there to special pages in my wiki, and it worked. For example, I went to my page MediaWiki:Cite_references_link_one and pasted there <li id="$1">'''[[#$2|↑]]''' $3</li>. And so on.

I'm so glad, that everything works just fine now.

Abagnale OS Ubuntu 11.04; MW 1.19.2; MySQL 5.1.61; PHP 5.2.1717:33, 1 November 2012

Cite failing to render citations

Product Version MediaWiki 1.20.3 PHP 5.3.23 MySQL 5.3.12

On the version page, cite is verified, but after trying to use it, it doesn't seem to want to generate citations. Any idea as to what might be going on here? Please help. Thanks!

Current behavior

According to scientists, the Sun is pretty big.<cite_reference_link> The Moon, however, is not so big.<cite_reference_link>


<cite_references_prefix><cite_references_link_one> <cite_references_link_one><cite_references_suffix>

Limebear (talk)22:23, 12 April 2013

Number of references

Is there a way to get the number of references on a page? I am trying to get the ref-list to automatically appear on pages but I don't want it to appear if there are no references being used.

Zackmann08 (talk)20:27, 5 March 2013

This should be relatively easy (and chpeap) to do through javascript (granted, readers with JS disabled will miss this feature).

i do not know a way to get this data displayed on the page directly (i.e., becoming part of the page directly, through wiki-code). it may be possible via scribunto (aka lua), but this will requires you to write some code also, so the advantage over JS is not clear (except for readers with JS disabled). and i'm not even sure if it's possible (and of course, if possible, it requires installing the scribunto extension).

here is a snippet that, if added to mediawiki:common.js will display the number of references under the page title (100% untested - this is meant mainly to illustrate):

if ( ! mw.config.get( 'wgNamespaceNumber' ) ) // only in namespace 0
$(function() {
    var num = $('ol.references  li[id|="cite_note"]').length
    if (num)
        $('#siteSub').append(' | ' + num + ' Cite notes');


קיפודנחש (talk)15:26, 6 March 2013

reading the original request more carefully, my reply was not very useful.

you can still use JS to *hide* the "references" section in case it's empty, but it may not be very pretty - the section will momentarily appear, and only after the page finishes rendering it will disappear (somewhat like "collapsible" elements). it will also not solve the case where there *are* references but no <references /> section.

again, you can use a pre-save JS hook that will at least warn the user when they are going to save a page with <ref> tags but no <references/> tag. you want to be careful, and not trigger the warning when editing a section.


קיפודנחש (talk)16:31, 6 March 2013

Actually, I have the <references /> tag on almost any page, embedded as it is in a template so that I don't have to remind myself of adding it manually. When no references are used on the page, the list simply does not appear. The only nuisance is that I can't make the subheading (e.g. "References" or "Endnotes") conditional on the presence of <ref>...</ref> tags. The subheading appears regardless.

Cavila (MW 1.19.2, MySQL 5.1.66, Php 5.3.3-7, SMW 1.8, SF 1.5.2}08:05, 7 March 2013

the little snippet above can do it, if you replace "if num > 0" with "if (num == 0)" or simply "if (! num)", and the action should be something like "$('ol.references').closest('h2').toggle(false)" or something similar.


קיפודנחש (talk)16:45, 7 March 2013

Mimic Wikipedia's Cite

Is there a process so that I could mimic Wikipedia's Cite extension?
I downloaded and installed the Cite extension, to test it I copied a page from Wikipedia onto my wiki. I ended up getting errors about nonexistant Cite groups and missing Templates. I began to copy Cite Templates from Wikipedia to my wiki and now I get a Fatal Error timeout., 7 January 2013

different wikis (such as enwiki) wrap the references with templates. if you want to use this extension in the simplest way, do not use any templates, but rather use the tags: the cites themselves appear on the page between tags <ref> and </ref>, and then, somewhere on the page (customarily at the end), you also need a <references /> tag (i.e., a self-closing "references" tag).

once you get this to work, you can start to play with more advanced features, and specifically with the "name" and "group" attributes.


קיפודנחש (talk)22:34, 7 January 2013

Thank you for your response. I have the Cite extension working, but when I try to mimic Wikipedia I begin to get problems., 8 January 2013

you can move (i.e., copy) templates from enwiki to your site, but you want to pay attention to some things:

  • there are other extensions installed in enwiki. specifically, Extension:ParserFunctions, which some templates depend on.
  • enwiki templating is pretty complex, and many templates use other templates. if you want to pull a template from enwiki, you need to pull (recursively) all the tempalates that this template uses.


קיפודנחש (talk)19:43, 8 January 2013

Ah I see. One of the big problems was that I did not have ParserFunctions enabled. Are there other big extensions that I would need?

I am still receiving the error where Cite cannot find the name/group, but when I check the backend they are present., 9 January 2013

it's really hard to guess like this. i think parserfunction is the main one. if your wiki is public, maybe post the url here, including the name of the article where the problem can be seen. otherwise, i'm afraid i do not know what might be the problem...


קיפודנחש (talk)23:42, 10 January 2013
First page
First page
Previous page
Previous page
Last page
Last page