[TYPO3-commerce] HOWTO create a 'read more' link at the end of the teaser text

Franz Koch typo.removeformessage at fx-graefix.de
Thu Oct 25 14:14:47 CEST 2007


Hi Michiel,

> I would like to create a 'read more' link at the end of the teaser text. 
> I inspected the docs of stdWrap and found that this should be possible 
> using postCObject. Appending text works, even links, but not the link 
> with the commerce parameters embedded.
> 
> I have tried the following to no avail:
> 
> plugin.tx_commerce_pi1 {
>     listView.products.fields {
>         # this part works fine ;-)
>         teaser.postCObject = COBJ_ARRAY
>         teaser.postCObject.10 = TEXT
>         teaser.postCObject.10 {
>             value = [
>         }
> 
>         # I gather from setup.txt that this is the way:
>         teaser.postCObject.20 < lib.tx_commerce.stdField
>         teaser.postCObject.20 {
>             value = lees meer  >>
>             typolink.setCommerceValues = 1
>             typolink.useCacheHash = 1
>         }
> 
>         # the above should be the same as this:
>         teaser.postCObject.25 = stdWrap
>         teaser.postCObject.25 {
>             cObject = TEXT
>             cObject.value = lees meer >>
>             setContentToCurrent = 1
>             if.isTrue.current  = 1
>             wrap = |
>             #value = lees meer  >>
>             typolink.setCommerceValues = 1
>             typolink.useCacheHash = 1
>         }
> 
>         # this part works fine ;-)
>         teaser.postCObject = COA
>         teaser.postCObject.30 = TEXT
>         teaser.postCObject.30 {
>             value = ]
>         }   
>     }
> }
> 
> The braces display fine, so somthing works :-)

due to the (in my eyes stupid) processing of the TS inside commerce, 
your setup will not work. That's because commerce checks for 
'setCommerceValues' only in the first level of the TS (and as far as I 
remember inside 'stdWrap.'). So the nested arguments in your case are 
not detected by commerce and thus will not be replaced with the correct 
paramters.

Instead of parsing the TS-tree for the phrase 'setCommerceValues' it'll 
be far better to just register the typolink parameters from within php, 
so that they are available EVERYWHERE in TS and so that this would work:
-----
teaser.postCObject.20 {
	typolink.parameter = {register:commerce_linkToProduct}
	typolink.parameter.insertData = 1
}
-----
The second thing that has to be changed would be to use a local cObject 
for parsing the code, which contains the data of the current result row. 
Then the possibilities would almost be endless - but well - I already 
mentioned this some time ago and nobody cared. So what.



To get it up and running with current commerce handling, try the following:
-----
	teaser >
	teaser = TEXT
	teaser {
		setContentToCurrent = 1
		# teaser
		prepend = TEXT
		prepend.current = 1

		# the more link
		cObject = TEXT
		cObject.value = more
		innerWrap = [|]
		typolink.setCommerceValues = 1
		typolink.useCacheHash = 1
	}
}
----
Using the cObject for the moreLink is necessary, because commerce seems 
to overwrite any value set by 'teaser.value = xy'.

--
Greetings,
Franz


More information about the TYPO3-project-commerce mailing list