FANDOM


m (Moviesign moved page Template:MakeIndex4 to Template:MakeIndex without leaving a redirect)
m (doc link, catgs)
Line 1: Line 1:
{{#dpl:execandexit=geturlargs}}
+
<includeonly>{{#dpl:execandexit=geturlargs}}
 
{{#dpl:
 
{{#dpl:
 
| allowcachedresults = false
 
| allowcachedresults = false
Line 9: Line 9:
 
| tablerow = %%,%%,%%
 
| tablerow = %%,%%,%%
 
| tablesortcol = 3
 
| tablesortcol = 3
}}
+
}}</includeonly><noinclude>
  +
{{Documentation}}
  +
[[Category:Templates]]
  +
[[Category:Utility templates]]
  +
</noinclude>

Revision as of 15:23, May 1, 2015

[edit] [purge] Template-info Template documentation

Description

This is a DPL (Dynamic Page List) template that generates an alphabetical index for items that have been designated using the {{P}} template. This is primarily intended for use in articles about a sourcebook or novel that could benefit from an index of some kind. You can index anything, but typically this will be creatures, characters, locations, magic items, etc. The output of this template is an alphabetical listing of the designated items with their page number(s).

Tagging Items

In an article, mark terms that you want to appear in the index like so:

... {{P|[[Death tyrant]]|13, 44, 46}} • {{P|[[Rothe|Deep Rothé]]|18|Deep Rothé}}
 • [[Dire bear]] • [[Dire lion]] • {{P|[[Displacer beast]]|102}} ...

The {{P}} template will simply echo the first parameter, so {{P|[[Death tyrant]]|13, 44, 46}} just looks like Death tyrant to the reader. However, the second parameter is the page number(s) where death tyrants can be found in the sourcebook or novel. The sorting operates on the unlinked text of the first parameter, so normally [[Rothe|Deep Rothé]] would be sorted as Rothe|Deep Rothé, which would put it in the R section of the index. The optional third parameter is a sortkey which will determine alphabetically where in the index the item appears. In the example above, "Deep Rothé" was added as the third parameter, so Deep Rothé will be listed under D instead of R.

Adding the Link

The index is generated dynamically when this template is called with a page name. To see the index, you need to place a link somewhere in the article that you are writing for the reader to click. A handy template called {{IndexLink}} will do this for you. Just place it where a reader can see it and voila, you are done. If you don't like the default link text, then you may modify it by supplying a new text string like so:

{{IndexLink|Click me, I dare you!}}

When a reader clicks the link, they are taken to the dynamically generated index page, which for our example looks somewhat like this:

Page Index for PAGENAME.
   Name 	Page(s)
Death tyrant 	13, 44, 46 	
Deep Rothé 	18 	
Displacer beast 102 

PAGENAME will be a wiki link to the page that contains the index link. If for some reason you want to place a link in an article different than the one containing the {{P}} tags, then copy the following wiki code and replace {{FULLPAGENAME}} with the name of the page.

[{{fullurl:Template:MakeIndex|page={{#replace:{{FULLPAGENAME}}| |_}}}}&action=purge Click here for index]

Notes

  • For novels and other books that may have multiple versions on different types of media (hardback, paperback, eBook), page numbers will not be consistent. In this case, you may want to use chapter names or numbers instead.
  • There is likely an upper limit to how many {{P}} templates can be found on a page, but I don't know what it is yet.


Community content is available under CC-BY-SA unless otherwise noted.