Property: | Data type: | Description: | Default: |
|---|---|---|---|
pageID | int | uid of the page used for the links on each tag | 0 |
plug-in 1
Property: | Data type: | Description: | Default: |
|---|---|---|---|
startPage | string/stdWrap | Comma-separated list of page uid's or a stdWrap The default value simply points to the root page of the site. | startPage.data = leveluid:0 |
recursive | int | Number of levels to explore below each page defined in the startPage property. For infinite recursing just set a very large value (e.g. 255) | 255 |
referenceTable | string | Name of the table to fetch the data from | pages |
referenceFields | string | Comma-separated list of fields to fetch the data from | keywords |
references | indexed array of reference configurations -> referenceConfig | This property makes it possible to query several tables instead of just one. For each reference you can indicate a table, a list of fields and an additional SQL where clause See example of use in the “TypoScript examples” section below. | |
exclude | special | This property makes it possible to define some criteria of exclusion for the data being fetched. This is defined for the reference table and for any field of that table. Values that match are excluded. Several values can be set, separated with commas. If you look at the default value, it means that we put conditions on both the tt_content and the pages tables. Obviously these conditions will be used only if we are indeed querying either tt_content or pages. In the case of tt_content the criteria state that we must exclude content elements of Ctype “mailform” and any instance of the tag cloud plug-in itself. As for pages we exclude several types (spacer, sysFolder and recycler) and those not in menu. | exclude.tt_content.CType = mailform exclude.tt_content.list_type = vge_tagcloud_pi1 exclude.pages.doktype = 199,254,255 |
includeNotInMenu | boolean | Includes pages that are not in menu (when querying the pages table) or elements in pages that are not in menu (when querying the tt_content table, for example, on any other record that has a pid field). Default is to not include. | 0 |
splitChar | string | Character to use to split the values found in the reference fields. If left empty, values are split along word boundaries. | |
splitWords | string | Regular expression for splitting the words along their boundaries Please refer to “A note about word boundaries” below | [-.,;:"&%()<>!?/'\s] |
caseHandling | string | How to handle the case of keywords. Leave empty to leave keywords as is. Set to lower to force to lower case, or upper to force to uppercase. | lower |
targetPage | int | uid of the page the links around each keyword should point to | {$plugin.tx_vgetagcloud_pi1.pageID} |
sorting | string | Criterion by which to sort the keywords before applying a limit to the number of keywords. Possible values are natural to avoid sorting the keywords, alpha (for alphabetical sorting) or weight. | weight |
sortOrder | string | Complements the above parameter with an order, either asc (ascending) or desc (descending) | desc |
maxWords | int | Maximum number of words to include in the tag cloud. Leave empty to include all words. | |
renderingType | string | Type of rendering to use. Select weight for relative weights or style for using a list of styles. | weight |
minWeight | int | Minimum weight to use for the relative weights type of rendering | 100 |
maxWeight | int | Maximum weight to use for the relative weights type of rendering | 200 |
styles | string | Comma-separated list of styles to use when rendering with styles | |
separator | string | Characters to insert between each keyword | |
sortingForDisplay | string | Criterion by which to sort the keywords for display. Possible values are natural to avoid sorting the keywords, alpha (for alphabetical sorting) or weight. | alpha |
sortOrderForDisplay | string | Complements the above parameter with an order, either asc (ascending) or desc (descending) | asc |
tagWrap | stdWrap | stdWrap property for each keyword in the tag cloud. The link placed on the keyword is defined in the stdWrap itself. See explanations below in “TypoScript examples” | tagWrap { dataWrap = <li style="font-size: {field:tag_style}%">|</li> typolink { parameter.data = field:tag_link additionalParams.dataWrap = &tx_vgetagcloud_pi3[pages]={field:tag_pages}&tx_vgetagcloud_pi3[keyword]={field:tag_keyword} ATagParams.dataWrap = id="tag{field:tag_id}" title="{field:tag_keyword}" } } |
cloudWrap | stdWrap | stdWrap for the complete tag cloud Note that the default value takes care of excluding the tag cloud's content from the indexed search engine. | cloudWrap.wrap = <!--TYPO3SEARCH_end--><ul>|</ul><div style="clear:both;"></div><!--TYPO3SEARCH_begin--> |
baseWrap | stdWrap | stdWrap for the whole of the plug-in's content. Use that if you don't want the content to be wrapped using pi_wrapInBaseClass(). | |
_CSS_DEFAULT_STYLE | string | The plug-in's configuration includes some basic styles that make the tag cloud display correctly. Use as a basis for your own styling. |
[tsref:plugin.tx_vgetagcloud_pi1]
-> referenceConfigs
Property: | Data type: | Description: | Default: |
|---|---|---|---|
table | string | Name of the table | |
fields | string | Comma-separated list of fields | |
where | string | Additional conditions to add to the SQL WHERE clause (do not start with “AND”) |
[tsref:plugin.tx_vgetagcloud_pi1.referenceConfigs]
plug-in 2
Property: | Data type: | Description: | Default: |
|---|---|---|---|
keyword | stdWrap | stdWrap for the keyword that was passed to the page in the “keyword” variable | keyword.wrap = <strong>|</strong> |
message | stdWrap | stdWrap for the result message displayed by the plug-in | message.wrap = <p>|</p> |
results | cObj | Content object for the rendering of the list of pages. The default is a simple hierarchical menu. | results = HMENU results { special = list special.value.field = tag_pages 1 = TMENU 1 { NO.allWrap = <li>|</li> } wrap = <ul>|</ul> } |
baseWrap | stdWrap | stdWrap for the whole of the plug-in's content. Use that if you don't want the content to be wrapped using pi_wrapInBaseClass(). |
[tsref:plugin.tx_vgetagcloud_pi2]
Several values are available for use inside the tagWrap property. They are dynamically defined for each keyword. They are:
tag_keyword: the keyword itself
tag_link: the id of the page to link to
tag_weight: the absolute weight of the keyword (i.e. the number of occurrences)
tag_style: the relative weight or style from the list that apply to this keyword
tag_id: an incremented unique number that can be used if you want to place a “id” attribute on each keyword
tag_pages: a list of page numbers the keyword was found in, separated by underscores.
Below are examples of use.
Default setup
The default value of the tagWrap property makes use of most of the special values introduced above:
plugin.tx_vgetagcloud_pi1
tagWrap {typolink {parameter.data = field:tag_link
additionalParams.dataWrap = &tx_vgetagcloud_pi2[pages]={field:tag_pages} &tx_vgetagcloud_pi2[keyword]={field:tag_keyword}ATagParams.dataWrap = id="tag{field:tag_id}" title="{field:tag_keyword}"useCashHache = 1
}
dataWrap = <li style="font-size: {field:tag_style}%">|</li>}
}
Let's look at the above code in detail. First of all we define the link that should be placed around the keyword using the typolink property. The target of the typolink is set using the tag_link special value, since it contains the number of the page to link to. Then we define additional parameters to add to the link. It should use the tag_keyword value (which contains the keyword itself) and set it as the value of the tx_vgetagcloud_pi2[keyword] query parameter. The same goes for tag_pages which is used as the value of tx_vgetagcloud_pi2[pages]. This second parameter is the critical one. Without it, the results page will not know what pages to display. The first one (keyword) is only important if you want to display the keyword as a reminder.
What is more, we add a unique id attribute to the A tag thanks to the tag_id special value and repeat the keyword itself in the title attribute. Lastly the link is wrapped inside a list item, on which the relative weight is applied as a percentage of font size, using the tag_style special value.
Note the activation of useCacheHash in the typolink setup. This is necessary because the link refers to the pi2 plugin which is cached (its type is USER). If the useCacheHash is not enabled you risk running into the empty cHash problem (if you don't understand what this is all about, please refer to the article, “The Mysteries of &cHash”, http://typo3.org/development/articles/the-mysteries-of-chash/).
The wrap around the cloud completes the setup:
plugin.tx_vgetagcloud_pi1.cloudWrap.wrap = <!--TYPO3SEARCH_end--><ul>|</ul><div style="clear:both;"></div><!--TYPO3SEARCH_begin-->
All tags are wrapped inside an unordered list and search engine markers are set so that the tag cloud is not indexed. The default styles provided by the extension ensure that the tags are displayed as floating elements and not as actual list items.
Linking to the indexed search engine
Using the individual keywords from the tag cloud to launch a search is very easy. Little configuration needs to be changed from the default setup.
plugin.tx_vgetagcloud_pi1
tagWrap {typolink {additionalParams >
additionalParams.data = field:tag_keyword
additionalParams.wrap = &tx_indexedsearch[sword]=|
}
}
}
Of course the destination of the typolinks must be a page containing the indexed search plug-in.
Linking to tt_news and TIMTAB
This example shows how to build a tag cloud based on tt_news. This means this method can also be used for basing a tag cloud on TIMTAB entries. Very little needs to be changed from the default setup.
plugin.tx_vgetagcloud_pi1
referenceTable = tt_news
referenceField = keywords
tagWrap {typolink {additionalParams >
additionalParams.data = field:tag_keyword
additionalParams.wrap = &tx_ttnews[swords]=|
}
}
}
With this each keyword will start a tt_news search. Of course, the links on the keywords must point to a page containing the tt_news plug-in with code SEARCH.
Querying multiple tables
The tag cloud can be built using data from multiple tables. This can only be achieved using TypoScript and not with the FlexForm configuration. Here is an example of such setup:
plugin.tx_vgetagcloud_pi1 { references { 1 { table = pages fields = title,keywords where = doktype = 1 } 2 { table = tt_content fields = header } 3 { table = tt_news fields = title } }}In this example code we decide to query three tables: the pages, the content elements and the news items. In the pages table, we will use the title and keywords fields, the header field of content elements and the title field of the news items. Furthermore the pages are restricted to being only of doktype = 1. This will be added to the WHERE clause of the SQL query that will run on the pages table.
Precedence of FlexForm and TypoScript
FlexForm settings always override TypoScript set up. The only exception to that is when querying multiple tables. In this case, the TypoScript property “references” is used no matter what values are entered into the FlexForm “Reference table” and “Reference fields” selectors.
Consistency between pi1 and pi2
Depending on your setup you must take care to ensure consistency between the pages found by pi1 and the pages displayed by pi2. In the latter the default rendering for the list of pages uses a HMENU content object. This object takes care of all the hassle of enable fields (hidden, deleted, access restrictions, publication dates), language overlay and versioning. The pi1 code does the same. But the HMENU object is also going to respect the “Not in menu” field. This is why the default pi1 setup excludes those pages (includeNotInMenu = 0). If you change this setup, you must also change the HMENU in pi2 to display the pages that are not in menu (results.includeNotInMenu = 1).
The “includeNotInMenu” property in the pi1 plug-in is also important, for example, when retrieving your keywords from content elements. With the default settings, the pi1 plug-in will not reference content elements on pages that are not in menu. That way when the pi2 is called, the results are coherent. If you want to take words also from not in menu pages, you have to set includeNotInMenu to 1 in both plug-ins setup.
In theory it is easy to split a block of text into single words. One needs only call the PHP function preg_split() and use the regular expression “\b”. In practice it is not quite that simple, at least when using UTF-8 encoding. In this case \b will split words on characters with diacritical marks (like é or ü) thus ruining the whole thing. In such a case it is necessary to be more specific, hence the TypoScript property “splitWords” to define which regular expression to use in preg_split() to find word boundaries.
The default value should cover most cases, but it is possible that you may have to modify it. Then again if you're just using English and no UTF-8 encoding, you may try to revert to simple “\b”.
Note that the TypoScript property is included inside a single-quoted string and that single quotes and forward slashes inside the regular expression will be escaped for proper syntax. If you want to split words along backslashes too, you need to escape the backslash yourself (i.e. type “\\”).
It is quite easy to set things up for the pi2 plug-in to work with RealURL. Here is an example configuration, but you may of course change if you know what you're doing:
$TYPO3_CONF_VARS['EXTCONF']['realurl'] = array(
'_DEFAULT' => array(
'postVarSets' => array(
'_DEFAULT' => array(
'tagcloud' => array(
array('GETvar' => 'tx_vgetagcloud_pi2[keyword]'),array('GETvar' => 'tx_vgetagcloud_pi2[pages]'))
)
)
)
)
This will produce URLs like http://www.mydomain.com/tag-cloud-results/tagcloud/somekeyword/1_2_3 when calling the page where an instance of the pi2 plug-in resides.