Difference between revisions of "Module: TextUtil"
From Genesys Documentation
(Created page with "local p = {} -- p stands for package local cargo = mw.ext.cargo -- conditional text switch on the Platform_ID assigned to each content area function getTemplateParam( frame,...") |
|||
(One intermediate revision by the same user not shown) | |||
Line 2: | Line 2: | ||
local cargo = mw.ext.cargo | local cargo = mw.ext.cargo | ||
− | -- | + | -- tried to use getPAGENAME function in findPlatform but had to use mw.title.getCurrentTitle directly instead |
+ | local function getPAGENAME () | ||
+ | return mw.title.getCurrentTitle().prefixedText | ||
+ | end | ||
− | function | + | function p.printPage() |
− | + | local page = getPAGENAME(page) | |
− | + | return page | |
− | |||
− | |||
− | |||
− | |||
end | end | ||
− | function | + | --query to find Platform_ID for a given Article (note all pages need to include cargo_store to Article Cargo table |
− | local | + | local function findPlatform () |
− | + | tables = 'Article,MintyDocsProduct,ContentAreaSection,DefinePlatforms' | |
− | + | fields = 'DefinePlatforms.Platform_ID=ID' | |
− | + | local args = { | |
− | return | + | join = 'Article.Product=MintyDocsProduct.displayname,MintyDocsProduct.contentarea=ContentAreaSection.DisplayName,ContentAreaSection.DisplayName=DefinePlatforms.Platform_Name', |
− | + | where = 'Article._pageName = "' .. mw.title.getCurrentTitle().prefixedText .. '"', | |
+ | } | ||
+ | local result = cargo.query( tables, fields, args ) | ||
+ | for i, row in ipairs(result) do | ||
+ | text = row.ID | ||
+ | end | ||
+ | return text | ||
end | end | ||
+ | |||
+ | --print conditional text for Genesys Cloud or Genesys Engage based on Platform_ID | ||
+ | |||
+ | function p.printCondition (frame) | ||
+ | local arg = findPlatform() | ||
+ | if arg == "2" then | ||
+ | return frame.args[1] | ||
+ | else | ||
+ | return frame.args[2] | ||
+ | end | ||
+ | end | ||
+ | |||
return p | return p |
Latest revision as of 21:34, January 17, 2022
Documentation for this module may be created at Module:TextUtil/doc
local p = {} -- p stands for package local cargo = mw.ext.cargo -- tried to use getPAGENAME function in findPlatform but had to use mw.title.getCurrentTitle directly instead local function getPAGENAME () return mw.title.getCurrentTitle().prefixedText end function p.printPage() local page = getPAGENAME(page) return page end --query to find Platform_ID for a given Article (note all pages need to include cargo_store to Article Cargo table local function findPlatform () tables = 'Article,MintyDocsProduct,ContentAreaSection,DefinePlatforms' fields = 'DefinePlatforms.Platform_ID=ID' local args = { join = 'Article.Product=MintyDocsProduct.displayname,MintyDocsProduct.contentarea=ContentAreaSection.DisplayName,ContentAreaSection.DisplayName=DefinePlatforms.Platform_Name', where = 'Article._pageName = "' .. mw.title.getCurrentTitle().prefixedText .. '"', } local result = cargo.query( tables, fields, args ) for i, row in ipairs(result) do text = row.ID end return text end --print conditional text for Genesys Cloud or Genesys Engage based on Platform_ID function p.printCondition (frame) local arg = findPlatform() if arg == "2" then return frame.args[1] else return frame.args[2] end end return p