[TYPO3-dev] how to implement "no records found" with TS
Martin Kutschker
martin.kutschker-n0spam at no5pam-blackbox.net
Mon Jul 10 21:31:10 CEST 2006
Peter Niederlag schrieb:
> Hi,
>
> Martin Kutschker schrieb:
>> Hi!
>>
>> I tried to display a message if a CONTENT object didn't render any
>> records. I didn't want to use a further SELECT (eg via stdWrap.numRows)
>> for performance reasons. I fiddled with cobj:parentRecordNumber with no
>> success.
>>
>> So I changed tlib_cObj:
>>
>> function getData($string,$fieldArray) {
>> ...
> [...]
>> Is this possible (without any additional SELECT!) without this hack?
>
> Well, you can use another TS-hack. ;)
>
> page {
> 20 = COA
> 20 {
> 50 < styles.content.get
> 50.stdWrap.ifEmpty = <h2>testme</h2>
> wrap = <div id="content">|</div>
> }
> }
>
> The only problem is that 'ifEmpty ' returns false if you have applied
> some wrap on the same TS-object. That's why you need that extra COA around.
Ah! Thanx to you and Joey. I hope I'm a better PHP coder than I'm a TS
coder ;-)
>> If not, do you think 'currentRecordTotal' should be added to getData?
>
> IMO this should go into a register, if its not there already, shouldn't it?
Basically yes. But tslib_cObj->getData() the method behind stdWrap.data
has already access to $this->parentRecordNumber via
cobj:parentRecordNumber so it was logical to give access to
$this->currentRecordTotal via cobj:currentRecordTotal.
Both suggested TS setups are fine, but the hack has the additional
benefit of delivering the total number of selected items.
Masi
More information about the TYPO3-dev
mailing list