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
int
ID of the #__ucm_content item being tagged- table
TableInterface
Table object being tagged- tags
array<string|int, mixed>
Array of tags to be applied.
Response
bool
true 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
mixed
If successful, metadata with new tag titles replaced by tag ids. Otherwise false.
deleteTagData
Method to delete the tag mappings and #__ucm_content record for for an item
deleteTagData(\Joomla\CMS\Table\TableInterface table, int|array contentItemId) :
since |
3.1 |
---|---|
throws |
|
Arguments
- table
TableInterface
Table 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
bool
true on success, false on failure
getCurrentLanguage
Gets the current language
getCurrentLanguage( detectBrowser = true) :
since |
3.2 |
---|
Arguments
- detectBrowser
bool
Flag indicating whether to use the browser language as a fallback.
Response
string
The 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
TableInterface
Table object.
Response
stdClass
Contains 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
string
Content type alias. Dot separated.- id
int
Id of the item to retrieve tags for.- getTagData
bool
If true, data from the tags table will be included, defaults to true.
Response
array<string|int, mixed>
Array of of tag objects
getLanguageId
Gets the associated language ID
getLanguageId( langCode) :
since |
3.2 |
---|
Arguments
- langCode
string
The language code to look up
Response
int
The 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
string
Content type alias. Dot separated.- ids
array<string|int, mixed>
Id of the item to retrieve tags for.- getTagData
bool
If true, data from the tags table will be included, defaults to true.
Response
array<string|int, mixed>
Array of 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
TableInterface
Table 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
mixed
The id or array of ids (primary key) of the item to be tagged.- prefix
string
Dot separated string with the option and view to be used for a url.
Response
string
Comma 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
mixed
Tag or array of tags to be matched- typesr
mixed
Null, type or array of type aliases for content types to be included in the results- includeChildren
bool
True to include the results from child tags- orderByOption
string
Column to order the results by- orderDir
string
Direction to sort the results in- anyOrAll
bool
True to include items matching at least one tag, false to include items all tags in the array.- languageFilter
string
Optional filter on language. Options are 'all', 'current' or any string.- stateFilter
string
Optional filtering on publication state, defaults to published or unpublished.
Response
DatabaseQuery
Query 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
int
An 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
string
Optionally 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
bool
If true, the alias is used to match, if false the type_id is used.
Response
array<string|int, mixed>
Array of 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 |
---|
Arguments
- table
TableInterface
Table being processed- newTags
array<string|int, mixed>
Array of new tags- replace
bool
Flag 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
TableInterface
Table 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
int
The 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
int
Id of the #__ucm_content item being tagged- table
TableInterface
Table object being tagged- tags
array<string|int, mixed>
Array of tags to be applied.- replace
bool
Flag indicating if all existing tags should be replaced
Response
bool
true 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
int
ID of the content item being untagged- table
TableInterface
Table object being untagged- tags
array<string|int, mixed>
Array of tags to be untagged. Use an empty array to untag all existing tags.
Response
bool
true 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