[TYPO3-english] Typoscript stdWrap if COA element not empty

Stefan Reichelt eichelt at web.de
Tue Jun 30 12:47:15 CEST 2015


Hello Arun,

although I have to agree with Bernd that you really should move the
wrapping into the same piece of code (you typoscript object would be
best imho).

But if you really really really reeeeally can't do that, here is a
possible solution (untested):

--
lib.contactbox = COA
lib.contactbox {
    10 < plugin.tx_myext_pi1

    # If empty, load a register and add a variable into it
    10.stdWrap.ifEmpty.cObject = LOAD_REGISTER
    10.stdWrap.ifEmpty.cObject.tx_myext_pi1_isEmpty = 1

    20 < styles.content.get
    20.select.where = colPos = 3

    # Only use wrap if register variable is not set
    stdWrap.wrap = |</div>
    stdWrap.wrap.if.isNull.data = register:tx_myext_pi1_isEmpty

    # Restore register to before last LOAD_REGISTER use
    99 = RESTORE_REGISTER
}

--

Instead of ifEmpty you could also try ifBlank. See which works better.

Instead of isNull you could also try isFalse. I don't know how
stdWrap.if handles register variables that do not exist. Please write
back which of them works. :)


Kind regards
Stefan

On 30/06/15 08:07, Arun Chandran wrote:
> Hi,
> 
> Yes. I know its little bit complicated. Opening and closing tags are in
> different places. But according to my requirement I need to implement like
> this. Can you suggest me a solution for this?
> 
> Thanks,
> Arun Chandran
> PIT Solutions Pvt Ltd.
> 
> On Tue, Jun 30, 2015 at 11:28 AM, bernd wilke <t3ng at bernd-wilke.net> wrote:
> 
>> Am 30.06.15 um 06:59 schrieb Arun Chandran:
>>
>>> Hi Guys,
>>>
>>> I've a typoscript configuration to build a small HTML structure. Starting
>>> of the HTML tag is in a plugin template and closing in typoscript. I mean;
>>>
>>> lib.contactbox = COA
>>> lib.contactbox {
>>>      10 < plugin.tx_myext_pi1
>>>
>>>      20 < styles.content.get
>>>      20.select.where = colPos = 3
>>>
>>>      wrap = |</div>
>>> }
>>>
>>> Here my extension start an HTML tag and closing is in typoscript. It works
>>> fine.
>>>
>>
>> no. it does not work fine. otherwise you would not have this problem.
>>
>>  But my problem is, if there is no content from plugin, then the close div
>>> tag is working which breaks HTML. So my requirement is only the wrap of
>>> closing div works when there is any content from plugin.
>>>
>>> I've tried the following script but not working;
>>>
>>> lib.contactbox = COA
>>> lib.contactbox {
>>>      stdWrap.wrap = |</div>
>>>      stdWrap.required = 1
>>>
>>>      10 < plugin.tx_myext_pi1
>>>
>>>      20 < styles.content.get
>>>      20.select.where = colPos = 3
>>> }
>>>
>>> If anybody knows the solution, then please help;
>>>
>>
>> you can build a very complicated structure to test whether your plugin
>> returns empty (copy the plugin inside your typoscript or store the value in
>> a register for two reads) but the easiest way is: close the div where the
>> information about emptyness is orinated: inside the plugin.
>>
>> I always use a variable for the return value of a function and try to have
>> only one exit at the end. In that way I can test for empty just before
>> returning and can append a closing div if not empty.
>>
>> in general I would avoid having opening and ending tags at different
>> places.
>> TYPO3 uses 'wraps', which means: something before and something after and
>> that is exact the structure of HTML: .wrap = opentag|closetag
>> Also this wraps (can) occur only if content is available avoiding empty
>> wraps: .required = 1
>>
>> bernd
>> --
>> http://www.pi-phi.de/cheatsheet.html
>>
>> _______________________________________________
>> TYPO3-english mailing list
>> TYPO3-english at lists.typo3.org
>> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-english
>>



More information about the TYPO3-english mailing list