DEPRECATION WARNING
This documentation is not using the current rendering mechanism and is probably outdated. The extension maintainer should switch to the new system. Details on how to use the rendering mechanism can be found here.
EXT: PMK HTMLCrop¶
Author: | Kasper Skårhøj |
---|---|
Created: | 2002-11-01T00:32:00 |
Changed: | 2009-10-19T17:51:35.140000000 |
Author: | Peter Klein |
Email: | pmk@io.dk |
Info 3: | |
Info 4: |
EXT: PMK HTMLCrop¶
Extension Key: pmkhtmlcrop
Copyright 2008, Peter Klein, <pmk@io.dk>
This document is published under the Open Content License
available from http://www.opencontent.org/opl.shtml
The content of this document is related to TYPO3
- a GNU/GPL CMS/Framework available from www.typo3.com
Table of Contents¶
EXT: PMK HTMLCrop 1
Introduction 1
What does it do? 1
Screenshots 1
Users manual 1
Adminstration 1
Configuration 1
Reference 2
Known problems 3
To-Do list 3
Changelog 3
Introduction¶
What does it do?¶
- Safe cropping of HTML content. Using this function instead of the standard crop, will fix problems where ending HTML tags has been cropped off. Which would otherwise result in XHTML errors and malformed output.
- Adds a new command (htmlCrop) to stdWrap using hook in TYPO3 v4.2+.
- Can be uses as a userFunc in older versions of TYPO3.
Screenshots¶
N/A
Users manual¶
Install the extension, and you can now use the new htmlCrop function in your own Typoscript scripts (or PHP scripts if running TYPO3 v4.2+)
Adminstration¶
N/A
Configuration¶
- 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)
- 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)
htmlCrop¶
Property
htmlCrop
Data type
Description
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.
Default
[tsref:->stdWrap]
((generated))¶
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 2 nd 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
Known problems¶
Not really a bug, but if the content from TYPO3's RTE contain custom tags like <link>, then the content must be parsed through the parseFunc before applying the htmlCrop, otherwise the custom tags will be removed.If anyone knows how to extend the PHP DOMDocument to include custom tags, please let me know.
To-Do list¶
Nothing, but if you got any suggestions, drop me an email.
Changelog¶
- 29-Apr-08Supressed output from loadHTML, so error messages doesn't get displayed.Fixed offset problem with cropping with negative values.Updated the manual.
- 19-Apr-08Changed hook from stdWrapPreProcess to stdWrapProcess.Fixed problem with encoding, due to content not having a header tag.Fixed problem with content not wrapped in any tag (like plain text)Thanks to Jochen Rau for reporting and testing the above fixes.
16-Apr-08Fixed small typing error. The word "div" was accidently spelled "dív" (Notice the wrong "i" char.)
01-Mar-08Initial release
EXT: PMK HTMLCrop - 3