luca
luca

Reputation: 12601

wrap a string in Typo3 only if not empty, and replace with message if empty

this is my typoscript:

nota = TEXT
nota.value = ###WFQBE_FIELD_nota###
nota.stdWrap {
   required = 1
   wrap = (|)
}
nota.ifEmpty = not available

I want to wrap the field nota in () only if not empty, if empty I want the message "not available" to appear.

This works, but the only problem is that the message gets wrapped in () too!!

Any idea? I'm a total newbe in Typoscript..

Upvotes: 2

Views: 10132

Answers (2)

Fedir RYKHTIK
Fedir RYKHTIK

Reputation: 9974

If I understood correctly, Your current problem is the "wrap".

As ifEmpty could be stdWrap too, try to override the wrap in ifEmpty condition.

nota = TEXT
nota.value = ###WFQBE_FIELD_nota###
nota.stdWrap {
   required = 1
   wrap = (|)
}
nota.ifEmpty.wrap = not available|

Upvotes: 3

konsolenfreddy
konsolenfreddy

Reputation: 9671

You can turn your condition around:

nota = TEXT
nota {
    value = not available
    override {
        cObject = TEXT
        cObject {
            required = 1
            value = ###WFQBE_FIELD_nota###
            wrap = (|)
        }
    }
}

Upvotes: 4

Related Questions