Knowledge-1.0

From WowAce Wiki
Jump to: navigation, search

API Documentation

Note: This documentation is auto-generated. Please note that direct modifications may be overwritten on next autogenerate.

:AddArticle(category , subCategory , article)

Arguments

category
string/integer - The article's category. Can be the name or the index.
subCategory
string/integer - The article's subcategory. Can be the name or the index. 0 or nil for no subcategory.
article
article - The article

Notes

  • An article is a table containing at least title (string) and text (string)
  • The article table:

{
title = "string", -- the articles title
[titleAlt = "string",] -- alternativ title
text = "string", -- the article content
[keywords = "string",] -- keywords for the search function (not used yet)
[languageId = integer,] -- language id, default value is the current language (not used by the KnowldegeBaseFrame)
[isHot = boolean,] -- mark the article as "hot"
[isNew = boolean,] -- mark the article as "new"
}

  • Warning: Knowledge-1.0 directly uses the given article table, so changes to the table are affecting the article.

Returns

  • integer - The article id (0 if there was an error)

Example

local article = {
  title = "Example",
  text  = "This is an example article.",
  isHot = true,
}
Knowledge:AddArticle("Example", "SubExample", article)

:AddCategory("name")

Arguments

"name"
string - The category's name/caption.

Notes

  • Creates a new category in the Knowledge Base.

Returns

  • integer - Category index

Example

Knowledge:AddCategory("Example")

:AddSubCategory(category , "name")

Arguments

category
string/integer - The main category. Can be the name or the index.
"name"
string - The subcategory's name.

Notes

  • Creates a new subcategory for the given category.

Returns

  • integer - Subcategory index (0 if there was an error)

Example

Knowledge:AddSubCategory("Example", "SubExample")

:GetCategoryIdByName("name")

Arguments

"name"
string - The category's name

Notes

  • This is used in :AddSubCategory and :AddArticle, so you can use the name as first parameter

Returns

integer - The category's index. nil if the category was not found.


:GetSubCategoryIdByName(category , "name")

Arguments

category
string/integer - The main category
"name"
string - The subcategory's name

Notes

  • This is used in ::AddArticle, so you can use the name as second parameter

Returns

integer - The subcategory's index. nil if the subcategory was not found.


:HasCategory(category)

Arguments

category
string/integer - The category.

Notes

  • You should check if a category exists, before you add it.

Returns

boolean - Is there a category called <category> or with the index <category>

Example

if not Knowledge:HasCategory("Example") then
  Knowledge:AddCategory("Example")
end

:HasSubCategory(category , subcategory)

Arguments

category
string/integer - The category.
subcategory
string/integer - The subcategory

Notes

  • You should check if a subcategory exists, before you add it.

Returns

boolean - Is there a subcategory for the given category called <subcategory> or with the index <subcategory>

Example

if not Knowledge:HasSubCategory("Example", "SubExample") then
  Knowledge:AddCategory("Example", "SubExample")
end

:OpenKnowledgeBase(categoryOrArticle , subCategory)

Arguments

categoryOrArticle
string/integer - The article id or the category id/name
subCategory
string/integer - The subcategory id or name

Notes

  • Opens the Knowledge Base to show the given article or category/subcategory

Returns

boolean - false if there was any error

Example

-- as an AceOptions entry:    
help = {
  type = "execute",
  name = "Help",
  desc = "Open the help frame.",
  func = function() Knowledge:OpenKnowledgeBase("Example", "SubExample") end,
}