TagsHelper

Extends CMSHelper

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

since

3.1

package

Application

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

intID of the #__ucm_content item being tagged

table

\Joomla\CMS\Table\TableInterfaceTable object being tagged

tags

arrayArray of tags to be applied.

Response

booltrue 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.

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

\InvalidArgumentException

Arguments

table

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

contentItemId

int|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

booltrue on success, false on failure

getCurrentLanguage

Gets the current language

getCurrentLanguage(bool detectBrowser = true) : string
inherited
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
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, int id, bool getTagData = true) : array
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

arrayArray of of tag objects

getLanguageId

Gets the associated language ID

getLanguageId(string langCode) : int
inherited
since

3.2

Arguments

langCode

stringThe language code to look up

Response

intThe 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, 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

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

\Joomla\Database\DatabaseQueryQuery 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(int id, array &tagTreeArray = array()) : mixed
since

3.1

Arguments

id

intAn optional ID

tagTreeArray

arrayArray 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
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 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

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

3.1

Arguments

table

\Joomla\CMS\Table\TableInterfaceTable being processed

newTags

arrayArray 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, 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(int tagId) : void
since

3.1

Arguments

tagId

intThe 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

intId of the #__ucm_content item being tagged

table

\Joomla\CMS\Table\TableInterfaceTable object being tagged

tags

arrayArray 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(int contentId, \Joomla\CMS\Table\TableInterface table, array tags = array()) : bool
since

3.1

Arguments

contentId

intID 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

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