Login / Status
developer.Resource
Home . Documentation . Document Library . Extension Manuals
Sponsors
hosted by punkt.deTYPO3 and Open Source Magazine

1.4. Configuration

  1. Once installed, you have access to a new stdWrap property called “htmlCrop”. The htmlCrop property has nearly the same options as the standard “crop” property. (It has an additional option where you can select an alternate trunkAt char (default is the space sharacter)

  2. The htmlCrop function can be used in other extension like tt_news, where you could display a cropped version of the bodytext field directly, instead of using the subheader field, or stripping off the HTML using the “stripHtml” property.

Reference

- Reference (TypoScript)

Property:

Data type:

Description:

Default:

htmlCrop

Crops the content to a certain length

Syntax: +/- (chars) = from left / from right | [string] | [boolean: keep whole words] | [trunkchar]

Examples:  

20 | ...    => max 20 characters. If more, the value will be truncated to first 20 chars and prepended with "..."

-20 | ... => max 20 characters. If more, the value will be truncated to last 20 chars and appended with "..."

20 | ... | 1 => max 20 characters. If more, the value will be truncated to last 20 chars and appended with "...". If the division is in the middle of a word, the remains of that word is removed. (text will be truncated to the position of the last space character.)

20 | ... | 1| .  => max 20 characters. If more, the value will be truncated to last 20 chars and appended with "...". If the division is in the middle of a sentence, the remains of that sentence  is removed. (text will be truncated to the position of the last period character.)

Uses "renderCharset" for the operation.

[tsref:->stdWrap]

Example

Example of usage using the htmlCrop function (TYPO3 v4.2+):

page = PAGE
page.typeNum = 0
page.10 = TEXT
page.10.value = <p>This is a <strong>HTML text</strong></p><p>It will be <em>cropped</em> with the <strong>htmlCrop</strong> function</p>
page.10.htmlCrop = 34 | ... [more]

Example of usage using the crop as a userFunc (TYPO3 versions lower than 4.2):

page = PAGE
page.typeNum = 0
page.10 = TEXT
page.10.value = <p>This is a <strong>HTML text</strong></p><p>It will be <em>cropped</em> with the <strong>htmlCrop</strong> function</p>
page.10.postUserFunc = tx_pmkhtmlcrop->htmlCrop
page.10.postUserFunc.htmlCrop = 9 | ... More

Here's a little Typoscript 'trick' that will allow you to insert a real link as the 2nd parameter (the 'moretext'), by using a custom register value to hold the link. (This also works using the standard 'crop' function in TYPO3)

5 = LOAD_REGISTER
5.morelink = Read More
5.morelink.typolink.parameter = http://www.typo3.org
10 = TEXT
10.value = <p>here <strong>is</strong> some text to be cropped</p>
10.htmlCrop = 9 | ... {register:morelink} | 1
10.insertData = 1