TagsHelper
扩展 CMSHelper标签助手类,提供执行与内容标记相关的各种任务的方法。
| 自 |
3.1 |
|---|---|
| 包 |
Joomla CMS |
方法
addTagMapping
用于向映射表添加标签行的方法。
addTagMapping( ucmId, \Joomla\CMS\Table\TableInterface table, mixed||string|int tags = []) :
| 自 |
3.1 |
|---|
参数
- ucmId
int正在标记的 #__ucm_content 项目的 ID- table
TableInterface正在标记的表对象- tags
array<string|int, mixed>要应用的标签数组。
响应
bool成功则为 true,否则为 false。
convertPathsToNames
将标签路径转换为名称路径的函数
convertPathsToNames(mixed||string|int tags) : mixed||string|int
| 自 |
3.1 |
|---|
参数
- tags
array<string|int, mixed>标签数组
响应
array<string|int, mixed>
createTagsFromField
通过查找字符串中的 #new# 来创建任何新标签
createTagsFromField(mixed||string|int tags) :
| 自 |
3.1 |
|---|
参数
- tags
array<string|int, mixed>来自字段的标签文本数组
响应
mixed如果成功,则使用新的标签标题替换标签 ID 的元数据。否则为 false。
deleteTagData
用于删除项目标签映射和 #__ucm_content 记录的方法
deleteTagData(\Joomla\CMS\Table\TableInterface table, int|array contentItemId) :
| 自 |
3.1 |
|---|---|
| 抛出 |
|
参数
- table
TableInterface发生删除的内容表的表对象- contentItemId
int|array<string|int, mixed>内容项目的 ID。或者键值对数组,其中数组键为主键名称,值是内容项目的 ID。注意不支持多个主键
响应
bool成功则为 true,失败则为 false
getCurrentLanguage
获取当前语言
getCurrentLanguage( detectBrowser = true) :
| 自 |
3.2 |
|---|
参数
- detectBrowser
bool指示是否将浏览器语言用作回退的标志。
响应
string语言字符串
getDataObject
获取包含所有表列和值的的对象的方法。
getDataObject(\Joomla\CMS\Table\TableInterface table) : \stdClass
getItemTags
获取项目标签列表的方法,可以选择包含标签数据。
getItemTags( contentType, id, getTagData = true) : mixed||string|int
| 自 |
3.1 |
|---|
参数
- contentType
string内容类型别名。点分隔。- id
int要检索标签的项目的 ID。- getTagData
bool如果为 true,则将包含来自标签表的 data,默认为 true。
响应
array<string|int, mixed>标签对象的数组
getLanguageId
获取关联的语言 ID
getLanguageId( langCode) :
| 自 |
3.2 |
|---|
参数
- langCode
string要查找的语言代码
响应
int语言 ID
getMultipleItemTags
获取多个项目标签列表的方法,可以选择包含标签数据。
getMultipleItemTags( contentType, mixed||string|int ids, getTagData = true) : mixed||string|int
| 自 |
4.2.0 |
|---|
参数
- contentType
string内容类型别名。点分隔。- ids
array<string|int, mixed>要检索标签的项目的 ID。- getTagData
bool如果为 true,则将包含来自标签表的 data,默认为 true。
响应
array<string|int, mixed>按 ID 分组的标签对象的数组。
getRowData
从表中获取一行数据
getRowData(\Joomla\CMS\Table\TableInterface table) : mixed||string|int
getTagIds
获取给定项目标签列表的方法。
getTagIds( ids, prefix) :
通常用于在布局中显示标签列表
| 自 |
3.1 |
|---|
参数
- ids
mixed要标记的项目的 ID 或 ID 数组(主键)。- prefix
string用于 URL 的选项和视图的点分隔字符串。
响应
string用逗号分隔的标签 ID 列表。
getTagItemsQuery
获取用于检索标签的详细项目列表的查询的方法。
getTagItemsQuery( tagId, typesr = null, includeChildren = false, orderByOption = 'c.core_title', orderDir = 'ASC', anyOrAll = true, languageFilter = 'all', stateFilter = '0,1') : \Joomla\Database\DatabaseQuery
| 自 |
3.1 |
|---|
参数
- tagId
mixed要匹配的标签或标签数组- typesr
mixed空、类型或内容类型别名数组,以包含在结果中的内容类型。- includeChildren
bool如果要包含子标签的结果,则为 true- orderByOption
string要按其排序结果的列- orderDir
string对结果进行排序的方向- anyOrAll
bool如果要包含至少匹配一个标签的项目,则为 true,如果要包含数组中所有标签的项目,则为 false。- languageFilter
string对语言的可选筛选器。选项为“all”、“current”或任何字符串。- stateFilter
string对发布状态的可选筛选器,默认为已发布或未发布。
响应
DatabaseQuery用于检索标签列表的查询
getTagNames
将标签 ID 转换为其标签名称的函数
getTagNames(mixed||string|int tagIds) : mixed||string|int
| 自 |
3.1 |
|---|
参数
- tagIds
array<string|int, mixed>整数标签 ID 数组。
响应
array<string|int, mixed>标签名称数组。
getTags
将标签 ID 转换为其标签 ID 和标签名称的函数
getTags(mixed||string|int tagIds) : mixed||string|int
| 自 |
4.4.0 |
|---|
参数
- tagIds
array<string|int, mixed>整数标签 ID 数组。
响应
array<string|int, mixed>标签 ID 和名称数组。
getTagTreeArray
获取当前标签及其子级的标签 ID 数组的方法
getTagTreeArray( id, mixed||string|int &tagTreeArray = []) :
| 自 |
3.1 |
|---|
参数
- id
int可选 ID- tagTreeArray
array<string|int, mixed>包含标签树的数组
响应
mixed
getTypes
获取包含关联数据的类型列表的方法。
getTypes( arrayType = 'objectList', mixed||string|int selectTypes = null, useAlias = true) : mixed||string|int
| 自 |
3.1 |
|---|
参数
- arrayType
string可以选择指定返回列表由对象、关联数组或数组组成。选项为:rowList、assocList 和 objectList- selectTypes
array<string|int, mixed>可选的类型 ID 或别名数组,用于将结果限制为这些 ID 或别名。通常来自请求。- useAlias
bool如果为 true,则使用别名进行匹配,如果为 false,则使用 type_id。
响应
array<string|int, mixed>类型数组
postStoreProcess
处理 store() 之后在表类中使用的标签保存的函数
postStoreProcess(\Joomla\CMS\Table\TableInterface table, mixed||string|int newTags = [], replace = true) :
| 自 |
3.1 |
|---|
参数
- table
TableInterface正在处理的表- newTags
array<string|int, mixed>新标签数组- replace
bool指示是否应替换所有现有标签的标志
响应
bool
preStoreProcess
在 store() 之前预处理来自表的数据的函数,以确保正确处理标签
preStoreProcess(\Joomla\CMS\Table\TableInterface table, mixed||string|int newTags = []) :
searchTags
用于搜索标签的函数
searchTags(mixed||string|int filters = []) : mixed||string|int
| 自 |
3.1 |
|---|
参数
- filters
array<string|int, mixed>要应用于搜索的筛选器
响应
array<string|int, mixed>
tagDeleteInstances
从映射表中删除标签的所有实例的方法。通常在删除标签时使用。
tagDeleteInstances( tagId) :
| 自 |
3.1 |
|---|
参数
- tagId
int要删除的标签的 tag_id(主键)。
响应
void
tagItem
用于添加或更新与项目关联的标签的方法。
tagItem( ucmId, \Joomla\CMS\Table\TableInterface table, mixed||string|int tags = [], replace = true) :
| 自 |
3.1 |
|---|
参数
- ucmId
int正在标记的 #__ucm_content 项目的 ID- table
TableInterface正在标记的表对象- tags
array<string|int, mixed>要应用的标签数组。- replace
bool指示是否应替换所有现有标签的标志
响应
bool成功则为 true,否则为 false。
unTagItem
用于取消标记项目的方法
unTagItem( contentId, \Joomla\CMS\Table\TableInterface table, mixed||string|int tags = []) :
| 自 |
3.1 |
|---|
参数
- contentId
int正在取消标记的内容项目的 ID- table
TableInterface正在取消标记的表对象- tags
array<string|int, mixed>要取消标记的标签数组。使用空数组来取消标记所有现有标签。
响应
bool成功则为 true,否则为 false。
属性
tagsChanged
用于存储和删除标签信息的助手对象。
| 自 |
3.1 |
|---|
类型
bool
replaceTags
是否替换所有标签还是只添加标签
| 自 |
3.1 |
|---|
类型
bool
typeAlias
用于查询映射和内容类型表的别名。
| 自 |
3.1 |
|---|
类型
string
itemTags
项目标签数组。
| 自 |
3.1 |
|---|
类型
array<string|int, mixed>
tags
标签作为逗号分隔的字符串或数组。
| 自 |
4.3.0 |
|---|
类型
mixed
newTags
新标签作为逗号分隔的字符串或数组。
| 自 |
4.3.0 |
|---|
类型
mixed
oldTags
旧标签作为逗号分隔的字符串或数组。
| 自 |
4.3.0 |
|---|
类型
mixed