Forum


Replies: 6   Views: 3453
Deletetemplateblock broken?
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by lbreu  · 18-01-2012 - 18:51

Hi

I just tried to use deleteTemplateBlock to remove a table when a list of items is empty, just like you try to do in your demo. However, only the tags $BLOCK_table$ are removed, not the actual content (a table, just like in your demo). I tried your demo with the IE and Firefox, LibreOffice and Word 2007, in all combinations the table is also still there in the final document.

Am I missing something? Did I not understand the idea behind deleteTemplateBlock()??

Would appreciate some hints and/or fixes...

Cheers,
Lorenz

Posted by lbreu  · 11-04-2013 - 12:13

Oops, posted too early, your demo works when I remove the empty input form, it seems, but still can't reproduce the functionality yet...

Posted by lbreu  · 11-04-2013 - 12:13

and another self-reply :)

Seems to be a LibreOffice problem. I rebuilt the template using M$ Word and it worked halfway, i.e. the table and the trailing $BLOCK_table$ where removed, the leading one was still there, probably some leftover artifact from LibreOffice.

Posted by lbreu  · 11-04-2013 - 12:13

solution:

use clearBlocks() at the end

Posted by gowrisankarn  · 01-07-2013 - 06:46

My Template:



$BLOCK_A$

TABLE COL1      COL2                   

$VAR_R_MAN$   $VAR_R_COST$

$BLOCK_A$ 



Code Snippet:



$docx->deleteTemplateBlock('BLOCK_A');



...



$docx->clearBlocks();



Output:



Doesn't delete the table within the block. I see below in my generated doc.



TABLE COL1      COL2                   

$VAR_R_MAN$   $VAR_R_COST$



Any suggestions please?



 


Posted by gowrisankarn  · 01-07-2013 - 06:57

[quote=gowrisankarn]



My Template:



$BLOCK_A$

TABLE COL1      COL2                   

$VAR_R_MAN$   $VAR_R_COST$

$BLOCK_A$ 



Code Snippet:



$docx->deleteTemplateBlock('BLOCK_A');



...



$docx->clearBlocks();



Output:



Doesn't delete the table within the block. I see below in my generated doc.



TABLE COL1      COL2                   

$VAR_R_MAN$   $VAR_R_COST$



Any suggestions please?



 



[/quote]



My mistake.



NO : $docx->deleteTemplateBlock('BLOCK_A');



YES : $docx->deleteTemplateBlock('A');



It is mentioned in one of the examples that the prefix "BLOCK_" will be omitted from the argument. Would be nice if this is document here http://www.phpdocx.com/api-documentation/templates/delete-Word-template-block-content.



Thank you.