Difference between revisions of "Module: TextUtil"

From Genesys Documentation
Jump to: navigation, search
(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,...")
 
Line 2: Line 2:
 
local cargo = mw.ext.cargo
 
local cargo = mw.ext.cargo
  
-- conditional text switch on the Platform_ID assigned to each content area
+
-- 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 getTemplateParam( frame, paramName )
+
function p.printPage()
  local val = frame:getParent().args[paramName]
+
    local page = getPAGENAME(page)
  if ( val == nil ) then
+
    return page
        return ''
 
    else
 
        return val
 
    end
 
 
end
 
end
  
function p.conditionalPlatform ( frame )
+
--query to find Platform_ID for a given Article (note all pages need to include cargo_store to Article Cargo table
       local val = frame:getParent().args[paramName]
+
local function findPlatform ()  
  if ( val == nil ) then
+
      tables = 'Article,MintyDocsProduct,ContentAreaSection,DefinePlatforms'
        return ''
+
      fields = 'DefinePlatforms.Platform_ID=ID'
    else
+
       local args = {
         return val
+
      join =  'Article.Product=MintyDocsProduct.displayname,MintyDocsProduct.contentarea=ContentAreaSection.DisplayName,ContentAreaSection.Platform_ID=DefinePlatforms.Platform_ID',
    end
+
        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

Revision as of 16:37, March 30, 2020

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.Platform_ID=DefinePlatforms.Platform_ID',
        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
Retrieved from "https://all.docs.genesys.com/Module:TextUtil (2025-06-21 13:39:40)"