|
|
| Line 72: |
Line 72: |
| template._blocks.navigation = { | | template._blocks.navigation = { |
| feature = 'navigation', | | feature = 'navigation', |
| render = function(template, args) | | render = ElementNavigation.createBlock() |
| -- Get configuration from template
| |
| local config = template.config.navigation or {}
| |
|
| |
| -- Get field names
| |
| local prevField = config.prevField or "has_previous"
| |
| local nextField = config.nextField or "has_next"
| |
|
| |
| -- Check for user-provided navigation values
| |
| local hasPrev = args[prevField]
| |
| local hasNext = args[nextField]
| |
|
| |
| -- If no navigation is provided at all, return empty string
| |
| if (not hasPrev or hasPrev == "") and (not hasNext or hasNext == "") then
| |
| return ""
| |
| end
| |
|
| |
| -- Determine previous and next pages
| |
| local prevPage = hasPrev and hasPrev ~= "" and hasPrev ~= "yes" and hasPrev ~= "true" and hasPrev or nil
| |
| local nextPage = hasNext and hasNext ~= "" and hasNext ~= "yes" and hasNext ~= "true" and hasNext or nil
| |
|
| |
| -- If no actual navigation links were found, return empty string
| |
| if not prevPage and not nextPage then
| |
| return ""
| |
| end
| |
|
| |
| -- Get styling options
| |
| local prevClass = "process-navigation-prev"
| |
| local nextClass = "process-navigation-next"
| |
| local prevLabel = config.prevLabel or "← Previous Process"
| |
| local nextLabel = config.nextLabel or "Next Process →"
| |
| local rowHeight = "40"
| |
|
| |
| -- Create navigation row
| |
| local output = {
| |
| '|-',
| |
| '| class="' .. prevClass .. '" height="' .. rowHeight .. '" valign="middle" |'
| |
| }
| |
|
| |
| -- Add previous link
| |
| if prevPage then
| |
| table.insert(output, string.format(
| |
| '<div class="process-nav-prev">[[%s|%s]]</div>',
| |
| prevPage, prevLabel
| |
| ))
| |
| else
| |
| table.insert(output, " ")
| |
| end
| |
|
| |
| -- Add next link cell
| |
| table.insert(output, '| class="' .. nextClass .. '" height="' .. rowHeight .. '" valign="middle" |')
| |
|
| |
| if nextPage then
| |
| table.insert(output, string.format(
| |
| '<div class="process-nav-next">[[%s|%s]]</div>',
| |
| nextPage, nextLabel
| |
| ))
| |
| else
| |
| table.insert(output, " ")
| |
| end
| |
|
| |
| return table.concat(output, "\n")
| |
| end
| |
| } | | } |
|
| |
|