TagsHelper

Extends \Joomla\CMS\Helper\CMSHelper

Tags helper class, provides methods to perform various tasks relevant tagging of content.

since

3.1

Methods

addTagMapping

Method to add tag rows to mapping table.

addTagMapping(integer $ucmId, \Joomla\CMS\Table\TableInterface $table, array $tags = array()) : boolean
since

3.1

Arguments

$ucmId

integerID of the #__ucm_content item being tagged

$table

\Joomla\CMS\Table\TableInterfaceTable object being tagged

$tags

arrayArray of tags to be applied.

Response

booleantrue on success, otherwise false.

convertPathsToNames

Function that converts tags paths into paths of names

convertPathsToNames(array $tags) : array
static
since

3.1

Arguments

$tags

arrayArray 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

arrayTags text array from the field

Response

mixedIf successful, metadata with new tag titles replaced by tag ids. Otherwise false.

createTagsFromMetadata

Create any new tags by looking for #new# in the metadata

createTagsFromMetadata(string $metadata) : mixed
deprecated
since

3.1

deprecated

4.0 This method is no longer used in the CMS and will not be replaced.

Arguments

$metadata

stringMetadata JSON string

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 for an item

deleteTagData(\Joomla\CMS\Table\TableInterface $table, integer|array $contentItemId) : boolean
since

3.1

throws

\InvalidArgumentException

Arguments

$table

\Joomla\CMS\Table\TableInterfaceTable object of content table where delete occurred

$contentItemId

integer|arrayID 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

booleantrue on success, false on failure

getCurrentLanguage

Gets the current language

getCurrentLanguage(boolean $detectBrowser = true) : string
inherited
since

3.2

Arguments

$detectBrowser

booleanFlag 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
inherited
since

3.2

Arguments

$table

\Joomla\CMS\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(string $contentType, integer $id, boolean $getTagData = true) : array
since

3.1

Arguments

$contentType

stringContent type alias. Dot separated.

$id

integerId of the item to retrieve tags for.

$getTagData

booleanIf true, data from the tags table will be included, defaults to true.

Response

arrayArray of of tag objects

getLanguageId

Gets the associated language ID

getLanguageId(string $langCode) : integer
inherited
since

3.2

Arguments

$langCode

stringThe language code to look up

Response

integerThe language ID

getRowData

Gets a row of data from a table

getRowData(\Joomla\CMS\Table\TableInterface $table) : array
inherited
since

3.2

Arguments

$table

\Joomla\CMS\Table\TableInterfaceTable instance for a row.

Response

arrayAssociative 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

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(mixed $tagId, mixed $typesr = null, boolean $includeChildren = false, string $orderByOption = 'c.core_title', string $orderDir = 'ASC', boolean $anyOrAll = true, string $languageFilter = 'all', string $stateFilter = '0,1') : \JDatabaseQuery
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

booleanTrue to include the results from child tags

$orderByOption

stringColumn to order the results by

$orderDir

stringDirection to sort the results in

$anyOrAll

booleanTrue 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

\JDatabaseQueryQuery 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

arrayArray of integer tag ids.

Response

arrayAn array of tag names.

getTagTreeArray

Method to get an array of tag ids for the current tag and its children

getTagTreeArray(integer $id,  &$tagTreeArray = array()) : mixed
since

3.1

Arguments

$id

integerAn optional ID

$tagTreeArray

Response

mixed

getTypeId

Method to get the type id for a type alias.

getTypeId(string $typeAlias) : string
deprecated
since

3.1

deprecated

4.0 Use \JUcmType::getTypeId() instead

Arguments

$typeAlias

stringA type alias.

Response

stringName of the table for a type

getTypes

Method to get a list of types with associated data.

getTypes(string $arrayType = 'objectList', array $selectTypes = null, boolean $useAlias = true) : array
static
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

arrayOptional array of type ids to limit the results to. Often from a request.

$useAlias

booleanIf true, the alias is used to match, if false the type_id is used.

Response

arrayArray 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(), boolean $replace = true) : boolean
since

3.1

Arguments

$table

\Joomla\CMS\Table\TableInterfaceTable being processed

$newTags

arrayArray of new tags

$replace

booleanFlag indicating if all exising tags should be replaced

Response

boolean

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\TableInterfaceTable being processed

$newTags

arrayArray of new tags

Response

null

searchTags

Function to search tags

searchTags(array $filters = array()) : array
static
since

3.1

Arguments

$filters

arrayFilter 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(integer $tag_id) : void
since

3.1

Arguments

$tag_id

integerThe tag_id (primary key) for the deleted tag.

tagItem

Method to add or update tags associated with an item.

tagItem(integer $ucmId, \Joomla\CMS\Table\TableInterface $table, array $tags = array(), boolean $replace = true) : boolean
since

3.1

Arguments

$ucmId

integerId of the #__ucm_content item being tagged

$table

\Joomla\CMS\Table\TableInterfaceTable object being tagged

$tags

arrayArray of tags to be applied.

$replace

booleanFlag indicating if all exising tags should be replaced

Response

booleantrue on success, otherwise false.

unTagItem

Method to untag an item

unTagItem(integer $contentId, \Joomla\CMS\Table\TableInterface $table, array $tags = array()) : boolean
since

3.1

Arguments

$contentId

integerID of the content item being untagged

$table

\Joomla\CMS\Table\TableInterfaceTable object being untagged

$tags

arrayArray of tags to be untagged. Use an empty array to untag all existing tags.

Response

booleantrue on success, otherwise false.

Properties

tagsChanged

Helper object for storing and deleting tag information.

since

3.1

Type(s)

boolean

replaceTags

Whether up replace all tags or just add tags

since

3.1

Type(s)

boolean

typeAlias

Alias for querying mapping and content type table.

since

3.1

Type(s)

string