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(int ucmId, \Joomla\CMS\Table\TableInterface table, array tags = array()) : bool
since |
3.1 |
---|
Arguments
- ucmId
int
ID of the #__ucm_content item being tagged- table
\Joomla\CMS\Table\TableInterface
Table object being tagged- tags
array
Array of tags to be applied.
Response
bool
true on success, otherwise false.
convertPathsToNames
Function that converts tags paths into paths of names
convertPathsToNames(array tags) : array
since |
3.1 |
---|
Arguments
- tags
array
Array of tags
Response
array
createTagsFromField
Create any new tags by looking for #new# in the strings
createTagsFromField(array tags) : mixed
since |
3.1 |
---|
Arguments
- tags
array
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) : bool
since |
3.1 |
---|---|
throws |
|
Arguments
- table
\Joomla\CMS\Table\TableInterface
Table object of content table where delete occurred- contentItemId
int|array
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(bool detectBrowser = true) : string
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
\Joomla\CMS\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(string contentType, int id, bool getTagData = true) : array
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
Array of of tag objects
getLanguageId
Gets the associated language ID
getLanguageId(string langCode) : int
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(string contentType, array ids, bool getTagData = true) : array
since |
4.2.0 |
---|
Arguments
- contentType
string
Content type alias. Dot separated.- ids
array
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
Array of of tag objects grouped by Id.
getRowData
Gets a row of data from a table
getRowData(\Joomla\CMS\Table\TableInterface table) : array
since |
3.2 |
---|
Arguments
- table
\Joomla\CMS\Table\TableInterface
Table instance for a row.
Response
array
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(mixed ids, string prefix) : string
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(mixed tagId, mixed typesr = null, bool includeChildren = false, string orderByOption = 'c.core_title', string orderDir = 'ASC', bool anyOrAll = true, string languageFilter = 'all', string 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
\Joomla\Database\DatabaseQuery
Query to retrieve a list of tags
getTagNames
Function that converts tag ids to their tag names
getTagNames(array tagIds) : array
since |
3.1 |
---|
Arguments
- tagIds
array
Array of integer tag ids.
Response
array
An array of tag names.
getTagTreeArray
Method to get an array of tag ids for the current tag and its children
getTagTreeArray(int id, array &tagTreeArray = array()) : mixed
since |
3.1 |
---|
Arguments
- id
int
An optional ID- tagTreeArray
array
Array containing the tag tree
Response
mixed
getTypes
Method to get a list of types with associated data.
getTypes(string arrayType = 'objectList', array selectTypes = null, bool useAlias = true) : array
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
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
Array of of types
postStoreProcess
Function that handles saving tags used in a table class after a store()
postStoreProcess(\Joomla\CMS\Table\TableInterface table, array newTags = array(), bool replace = true) : bool
since |
3.1 |
---|
Arguments
- table
\Joomla\CMS\Table\TableInterface
Table being processed- newTags
array
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, array newTags = array()) : null
since |
3.1 |
---|
Arguments
- table
\Joomla\CMS\Table\TableInterface
Table being processed- newTags
array
Array of new tags
Response
null
searchTags
Function to search tags
searchTags(array filters = array()) : array
since |
3.1 |
---|
Arguments
- filters
array
Filter to apply to the search
Response
array
tagDeleteInstances
Method to delete all instances of a tag from the mapping table. Generally used when a tag is deleted.
tagDeleteInstances(int tagId) : void
since |
3.1 |
---|
Arguments
- tagId
int
The tag_id (primary key) for the deleted tag.
tagItem
Method to add or update tags associated with an item.
tagItem(int ucmId, \Joomla\CMS\Table\TableInterface table, array tags = array(), bool replace = true) : bool
since |
3.1 |
---|
Arguments
- ucmId
int
Id of the #__ucm_content item being tagged- table
\Joomla\CMS\Table\TableInterface
Table object being tagged- tags
array
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(int contentId, \Joomla\CMS\Table\TableInterface table, array tags = array()) : bool
since |
3.1 |
---|
Arguments
- contentId
int
ID of the content item being untagged- table
\Joomla\CMS\Table\TableInterface
Table object being untagged- tags
array
Array of tags to be untagged. Use an empty array to untag all existing tags.
Response
bool
true on success, otherwise false.