Module:ConceptNavbox

From No Subject
Jump to navigation Jump to search


Module:ConceptNavbox

This module renders the psychoanalytic concept navigation box used on concept articles. It is the Lua renderer behind {{ConceptNavbox}}, converting structured data from Module:ConceptNavbox/data into a standard {{Navbox}}.

What it does

  • Reads parameters passed from {{ConceptNavbox}} (or direct #invoke calls).
  • Loads group/link data from Module:ConceptNavbox/data using mw.loadData.
  • Populates group1/list1, group2/list2, etc.
  • Renders output by calling {{Navbox}}.

Dependencies

This module assumes these pages exist:

Interface

Main entry point:

Most editors should use:

Parameters

state

Controls whether the navbox is expanded or collapsed by default.

  • collapsed (default)
  • expanded
title

Overrides the navbox title text. Default: Psychoanalytic concepts

Usage

On articles (recommended)

Place near the end of a concept page, before category tags:

{{ConceptNavbox}}

Direct invocation (testing / advanced)

{{#invoke:ConceptNavbox|main}}
{{#invoke:ConceptNavbox|main|state=expanded}}
{{#invoke:ConceptNavbox|main|title=Core concepts}}

Editing the concept lists

Do not edit this module to add/remove links. Edit:

Common errors

  • Navbox missing: Ensure Template:Navbox exists and is named exactly Navbox.
  • Data missing: Ensure Module:ConceptNavbox/data exists and returns a table with rows.
  • Blank output: Check that rows is a numerically indexed array and each row has group and list fields.

See also


-- Module:ConceptNavbox
-- Minimal pattern: store groups in Module:ConceptNavbox/data and render via Module:Navbox

local p = {}

function p.main(frame)
  local args = frame:getParent() and frame:getParent().args or frame.args
  local state = args.state or "collapsed"
  local title = args.title or "Psychoanalytic concepts"

  local data = mw.loadData("Module:ConceptNavbox/data") -- a Lua table you maintain
  local nav = {
    name = "ConceptNavbox",
    title = title,
    state = state,
    navbar = "plain",
    listclass = "hlist",
  }

  for i, row in ipairs(data.rows) do
    nav["group" .. i] = row.group
    nav["list" .. i]  = row.list
  end

  return frame:expandTemplate{ title = "Navbox", args = nav }
end

return p