TagsHelper
Extends CMSHelperTags helper class, provides methods to perform various tasks relevant tagging of content.
| since |
3.1 |
|---|---|
| package |
Joomla CMS |
Methods
addTagMapping
Method to add tag rows to mapping table.
addTagMapping( ucmId, \Joomla\CMS\Table\TableInterface table, mixed||string|int tags = []) :
| since |
3.1 |
|---|
Arguments
- ucmId
intID of the #__ucm_content item being tagged- table
TableInterfaceTable object being tagged- tags
array<string|int, mixed>Array of tags to be applied.
Response
booltrue on success, otherwise false.
convertPathsToNames
Function that converts tags paths into paths of names
convertPathsToNames(mixed||string|int tags) : mixed||string|int
| since |
3.1 |
|---|
Arguments
- tags
array<string|int, mixed>Array of tags
Response
array<string|int, mixed>
createTagsFromField
Create any new tags by looking for #new# in the strings
createTagsFromField(mixed||string|int tags) :
| since |
3.1 |
|---|
Arguments
- tags
array<string|int, mixed>Tags text array from the field
Response
mixedIf successful, metadata with new tag titles replaced by tag ids. Otherwise false.
deleteTagData
Method to delete the tag mappings and #__ucm_content record for an item
deleteTagData(\Joomla\CMS\Table\TableInterface table, int|array contentItemId) :
| since |
3.1 |
|---|---|
| throws |
|
Arguments
- table
TableInterfaceTable object of content table where delete occurred- contentItemId
int|array<string|int, mixed>ID of the content item. Or an array of key/value pairs with array key being a primary key name and value being the content item ID. Note multiple primary keys are not supported
Response
booltrue on success, false on failure
getCurrentLanguage
Gets the current language
getCurrentLanguage( detectBrowser = true) :
| since |
3.2 |
|---|
Arguments
- detectBrowser
boolFlag indicating whether to use the browser language as a fallback.
Response
stringThe language string
getDataObject
Method to get an object containing all of the table columns and values.
getDataObject(\Joomla\CMS\Table\TableInterface table) : \stdClass
| since |
3.2 |
|---|
Arguments
- table
TableInterfaceTable object.
Response
stdClassContains all of the columns and values.
getItemTags
Method to get a list of tags for an item, optionally with the tag data.
getItemTags( contentType, id, getTagData = true) : mixed||string|int
| since |
3.1 |
|---|
Arguments
- contentType
stringContent type alias. Dot separated.- id
intId of the item to retrieve tags for.- getTagData
boolIf true, data from the tags table will be included, defaults to true.
Response
array<string|int, mixed>Array of tag objects
getLanguageId
Gets the associated language ID
getLanguageId( langCode) :
| since |
3.2 |
|---|
Arguments
- langCode
stringThe language code to look up
Response
intThe language ID
getMultipleItemTags
Method to get a list of tags for multiple items, optionally with the tag data.
getMultipleItemTags( contentType, mixed||string|int ids, getTagData = true) : mixed||string|int
| since |
4.2.0 |
|---|
Arguments
- contentType
stringContent type alias. Dot separated.- ids
array<string|int, mixed>Id of the item to retrieve tags for.- getTagData
boolIf true, data from the tags table will be included, defaults to true.
Response
array<string|int, mixed>Array of tag objects grouped by Id.
getRowData
Gets a row of data from a table
getRowData(\Joomla\CMS\Table\TableInterface table) : mixed||string|int
| since |
3.2 |
|---|
Arguments
- table
TableInterfaceTable instance for a row.
Response
array<string|int, mixed>Associative array of all columns and values for a row in a table.
getTagIds
Method to get a list of tags for a given item.
getTagIds( ids, prefix) :
Normally used for displaying a list of tags within a layout
| since |
3.1 |
|---|
Arguments
- ids
mixedThe id or array of ids (primary key) of the item to be tagged.- prefix
stringDot separated string with the option and view to be used for a url.
Response
stringComma separated list of tag Ids.
getTagItemsQuery
Method to get a query to retrieve a detailed list of items for a tag.
getTagItemsQuery( tagId, typesr = null, includeChildren = false, orderByOption = 'c.core_title', orderDir = 'ASC', anyOrAll = true, languageFilter = 'all', stateFilter = '0,1') : \Joomla\Database\DatabaseQuery
| since |
3.1 |
|---|
Arguments
- tagId
mixedTag or array of tags to be matched- typesr
mixedNull, type or array of type aliases for content types to be included in the results- includeChildren
boolTrue to include the results from child tags- orderByOption
stringColumn to order the results by- orderDir
stringDirection to sort the results in- anyOrAll
boolTrue to include items matching at least one tag, false to include items all tags in the array.- languageFilter
stringOptional filter on language. Options are 'all', 'current' or any string.- stateFilter
stringOptional filtering on publication state, defaults to published or unpublished.
Response
DatabaseQueryQuery to retrieve a list of tags
getTagNames
Function that converts tag ids to their tag names
getTagNames(mixed||string|int tagIds) : mixed||string|int
| since |
3.1 |
|---|
Arguments
- tagIds
array<string|int, mixed>Array of integer tag ids.
Response
array<string|int, mixed>An array of tag names.
getTags
Function that converts tag ids to their tag id and tag names
getTags(mixed||string|int tagIds) : mixed||string|int
| since |
4.4.0 |
|---|
Arguments
- tagIds
array<string|int, mixed>Array of integer tag ids.
Response
array<string|int, mixed>An array of tag id and name.
getTagTreeArray
Method to get an array of tag ids for the current tag and its children
getTagTreeArray( id, mixed||string|int &tagTreeArray = []) :
| since |
3.1 |
|---|
Arguments
- id
intAn optional ID- tagTreeArray
array<string|int, mixed>Array containing the tag tree
Response
mixed
getTypes
Method to get a list of types with associated data.
getTypes( arrayType = 'objectList', mixed||string|int selectTypes = null, useAlias = true) : mixed||string|int
| since |
3.1 |
|---|
Arguments
- arrayType
stringOptionally specify that the returned list consist of objects, associative arrays, or arrays. Options are: rowList, assocList, and objectList- selectTypes
array<string|int, mixed>Optional array of type ids or aliases to limit the results to. Often from a request.- useAlias
boolIf true, the alias is used to match, if false the type_id is used.
Response
array<string|int, mixed>Array of types
postStoreProcess
Function that handles saving tags used in a table class after a store()
postStoreProcess(\Joomla\CMS\Table\TableInterface table, mixed||string|int newTags = [], replace = true) :
| since |
3.1 |
|---|---|
| deprecated |
5.3 will be removed in 7.0 |
Arguments
- table
TableInterfaceTable being processed- newTags
array<string|int, mixed>Array of new tags- replace
boolFlag indicating if all existing tags should be replaced
Response
bool
preStoreProcess
Function that preProcesses data from a table prior to a store() to ensure proper tag handling
preStoreProcess(\Joomla\CMS\Table\TableInterface table, mixed||string|int newTags = []) :
| since |
3.1 |
|---|
Arguments
- table
TableInterfaceTable being processed- newTags
array<string|int, mixed>Array of new tags
Response
null
searchTags
Function to search tags
searchTags(mixed||string|int filters = []) : mixed||string|int
| since |
3.1 |
|---|
Arguments
- filters
array<string|int, mixed>Filter to apply to the search
Response
array<string|int, mixed>
tagDeleteInstances
Method to delete all instances of a tag from the mapping table. Generally used when a tag is deleted.
tagDeleteInstances( tagId) :
| since |
3.1 |
|---|
Arguments
- tagId
intThe tag_id (primary key) for the deleted tag.
Response
void
tagItem
Method to add or update tags associated with an item.
tagItem( ucmId, \Joomla\CMS\Table\TableInterface table, mixed||string|int tags = [], replace = true) :
| since |
3.1 |
|---|
Arguments
- ucmId
intId of the #__ucm_content item being tagged- table
TableInterfaceTable object being tagged- tags
array<string|int, mixed>Array of tags to be applied.- replace
boolFlag indicating if all existing tags should be replaced
Response
booltrue on success, otherwise false.
unTagItem
Method to untag an item
unTagItem( contentId, \Joomla\CMS\Table\TableInterface table, mixed||string|int tags = []) :
| since |
3.1 |
|---|
Arguments
- contentId
intID of the content item being untagged- table
TableInterfaceTable object being untagged- tags
array<string|int, mixed>Array of tags to be untagged. Use an empty array to untag all existing tags.
Response
booltrue on success, otherwise false.
Properties
tagsChanged
Helper object for storing and deleting tag information.
| since |
3.1 |
|---|
Type(s)
bool
replaceTags
Whether up replace all tags or just add tags
| since |
3.1 |
|---|
Type(s)
bool
typeAlias
Alias for querying mapping and content type table.
| since |
3.1 |
|---|
Type(s)
string
itemTags
Array of item tags.
| since |
3.1 |
|---|
Type(s)
array<string|int, mixed>
tags
The tags as comma separated string or array.
| since |
4.3.0 |
|---|
Type(s)
mixed
newTags
The new tags as comma separated string or array.
| since |
4.3.0 |
|---|
Type(s)
mixed
oldTags
The old tags as comma separated string or array.
| since |
4.3.0 |
|---|
Type(s)
mixed