ମଡ୍ୟୁଲ:See also

ଉଇକିପିଡ଼ିଆ‌ରୁ

This module produces a "See also: a, b and c" link. It implements the {{see also}} template.

Usage from wikitext[ସମ୍ପାଦନା]

This module cannot be used directly from #invoke. Instead, it can only be used through the {{see also}} template. Please see the template page for documentation.

Usage from other Lua modules[ସମ୍ପାଦନା]

Load the module:

local mSeealso = require('Module:See also')

You can then use the _seealso function like this:

mSeealso._seealso(options, ...)

The parameters following options are a list of link/display tables, used to generate the see also links. The first value in each table is the link, and is required. The link can be just a page name, or can include a section link if desired. Links specifying a section are automatically formatted as page § section, rather than the MediaWiki default of page#section.

The second value in each table is the display value, and is optional.

The options variable is an optional configuration table. The following fields are recognised:

  • altphrase - an alternative phrase to "See also". Should be a string, if specified.
  • selfref - set to true to flag the output as a self-reference to Wikipedia. (See the {{selfref}} template for more details on self-references.)

Example 1[ସମ୍ପାଦନା]

mSeealso._seealso(nil, {'A'})

Produces:

<div role="note" class="hatnote">See also: [[A]]</div>

Displays as:

Example 2[ସମ୍ପାଦନା]

mSeealso._seealso(nil, {'A'}, {'B'}, {'C'})

Produces:

<div role="note" class="hatnote">See also: [[A]], [[B]] and [[C]]</div>

Displays as:

Example 3[ସମ୍ପାଦନା]

mSeealso._seealso(nil, {'A', 'the letter "A"'}, {'B', 'the letter "B"'}, {'C', 'the letter "C"'})

Produces:

<div role="note" class="hatnote">See also: [[A|the letter "A"]], [[B|the letter "B"]] and [[C|the letter "C"]]</div>

Displays as:

Example 4[ସମ୍ପାଦନା]

mSeealso._seealso({altphrase = 'Another page to see', selfref = true}, {'A#B'})

Produces:

<div role="note" class="hatnote selfref">Another page to see: [[A#B|A § B]]</div>

Displays as:

Technical details[ସମ୍ପାଦନା]

This module uses Module:Hatnote to format the hatnote text, Module:TableTools to process the list of links, and Module:Arguments to fetch the arguments from wikitext.


--[[
-- This module produces a "ଆହୁରି ଦେଖନ୍ତୁ: a, b and c" link. It implements the
-- template {{see also}}.
--]]

local mHatnote = require('Module:Hatnote')
local mTableTools -- lazily initialise
local mArguments -- lazily initialise

local p = {}

function p.seealso(frame)
	mTableTools = require('Module:TableTools')
	mArguments = require('Module:Arguments')
	local args = mArguments.getArgs(frame, {parentOnly = true})
	local pages = {}
	for k, v in pairs(args) do
		if type(k) == 'number' then
			local numstring = tostring(k)
			local display = args['label ' .. numstring]
				or args['l' .. numstring]
			local page = {v, display}
			pages[k] = page
		end
	end
	pages = mTableTools.compressSparseArray(pages)
	if not pages[1] then
		return mHatnote.makeWikitextError(
			'no page names specified',
			'Template:See also#Errors',
			args.category
		)
	end
	local options = {
		altphrase = args.altphrase,
		selfref = args.selfref
	}
	return p._seealso(options, unpack(pages))
end

function p._seealso(options, ...)
	local altphrase = options and options.altphrase or 'ଆହୁରି ଦେଖନ୍ତୁ'
	local links = mHatnote.formatPageTables(...)
	links = mw.text.listToText(links)
	local text = altphrase .. ': ' .. links

	-- Pass options through.
	local hnOptions = {}
	hnOptions.selfref = options.selfref

	return mHatnote._hatnote(text, hnOptions)
end

return p