Help:Page existence

From SacredWiki
Revision as of 22:02, 10 October 2013 by Schot (talk | contribs) (1 revision: Updating our Help Pages)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
MediaWiki Handbook: Contents, Readers, Editors, Moderators, System admins +/-

Wikitext methods to determine whether a page exists:

method what links here <ref>applying "what links here" on a probed page shows the page on which this method is applied</ref> transclusion <ref>the probed page is counted as transcluded onto the page on which this method is applied; this shows up in the edit page of the latter, and on "what links here" on the probed page</ref> limitation usage interwiki link<ref>applies with a correct prefix, regardless of existence of the linked page</ref> pagename with anchor
#ifexist yes no<ref>If a page is conditionally transcluded, namely only if it exists, then if the then-part of the #ifexist is this transclusion, it counts as a transclusion anyway, even if the page does not exist. However, if the then-part of the #ifexist is the name of the page to be transcluded, and the else-part is e.g. the page "dummy", and we have outer double braces to transclude the page with this conditional name, then only real transclusions are listed.</ref> not more than now 500 on a page<ref>On Wikimedia wikis there is a maximum for the number of distinct pages for which #ifexist is called on a page. A call of #ifexist after a transclusion of the same page does not require an extra database query and is therefore not counted. A call beyond the maximum returns "false". The html-source of each page shows the counted number of calls, as well as the maximum. The maximum is currently 500, and it has been announced that this will be lowered to 100. [1] [2] w:wikipedia:Template limits.</ref> branching "does not exist" checks page existence correctly, but not the existence of the anchor
#ifeq applied to the transclusion and the link: equality means non-existence; this is applied in Template:Exists, where care is taken that the comparison is insensitive to the applicable conversions yes yes branching "exists" "exists"
linking: class="new" means non-existence yes no none seeing the page link in a style depending on existence class="extiw" checks page existence correctly, but not the existence of the anchor
Special:Allpages no no none seeing the page listed or not not listed n.a.
Special:PrefixIndex no no none seeing the page listed or not not listed n.a.

Examples:

{{Special:PrefixIndex/exist}} gives:


Another method is, of course, going to the web address concerned and seeing the content or a message that the page does not exist.

Branching applications

A typical application of existence detection is:

  • producing the content of a page if it exists, otherwise some default

with the important special case:

  • producing the content of a page if it exists, otherwise nothing

If the set of possible pages is limited then an alternative is creating them all, with the extra pages containing the default value(s), and unconditionally transcluding the pages.

CSS class

If existence is checked in order to hide red links, an alternative for {{#ifexist:foo|[[foo]]}} and {{exists|foo|[[foo]]}} is <span class="hidden-redlink">[[foo]]</span>, giving "foo", where we have the CSS specification

.hidden-redlink a.new { display: none; }

(which on Meta has been added to Mediawiki:Common.css).

Conversely an emphasized style could be used for red links, or only red links could be displayed.

Efficiency

When checking existence of a page through transclusion, any parameters can be used in the call, as long as the result does not happen to be equal to the link to the page. However, for the page counts the choice of parameters can make a difference in the case that the page exists. This can be taken into account when checking a possible member of a family of templates, such as those like w:Template:Data China. If we use 1=void the include size is small, but the preprocessor node count is somewhat large, while if we use for parameter 1 the name of a non-existing template the include size is larger, but the preprocessor node count is smaller; for the latter method preferably a salted template name (list) is used. If we do not define parameter 1 it depends on whether the template takes w:Template:Show data as default (like on the template page itself) or not. If it does, the counts are high.

Notes

<references group=""></references>

See also


Links to other help pages

Help contents
Meta · Wikinews · Wikipedia · Wikiquote · Wiktionary · Commons: · mw: · b: · s: · mw:Manual · Google
Versions of this help page (for other languages see further)
Meta · Wikinews · Wikipediahttp://en.wikipedia.org/index.php/Help:Page_existence · Wikiquote · Wiktionary
What links here on Meta or from Meta · Wikipedia · MediaWiki
Reading
Go · Search · Stop words · Namespace · Page name · Section · Backlinks · Redirect · Category · Image page · Special pages · Printable version
Tracking changes
Recent changes (enhanced) | Related changes · Watching pages · Diff · Page history · Edit summary · User contributions · Minor edit · Patrolled edit
Logging in and preferences
Logging in · Preferences · User style
Editing
Starting a new page · Advanced editing · Editing FAQ · Edit toolbar · Export · Import · Shortcuts · Edit conflict · Page size
Referencing
Links · URLs · Piped links · Interwiki linking · Footnotes
Style and formatting
Wikitext examples · CSS · Reference card · HTML in wikitext · Formula · List · Table · Sorting · Colors · Images and file uploads
Fixing mistakes
Show preview · Testing · Reverting edits
Advanced functioning
Expansion · Template · Advanced templates · Parser function · Parameter default · Variable · System message · Substitution · Array · Calculation · Embed page
Others
Special characters · Renaming (moving) a page · Talk page · Signatures · Sandbox · Legal issues for editors