You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using the PHPWord library to clone a block containing a multilevel numbered list in a DOCX document. However, I've noticed that the numbering inner levels in the cloned block continues from the original block, which is not the behavior I'm looking for. I'd like to reset the numbering in lists inside the new block.
Steps to Reproduce:
Clone a block containing a multilevel numbered list using the cloneBlock method.
Observe that the numbering in the cloned block continues from the original block.
Expected Behavior:
I would like to reset the numbering in the lists inside the cloned block so that they start from the beginning (e.g., 1, 2, 3...).
Current Implementation:
function cloneBlockInDocx($docx_path) {
// Load the Word document
$phpword = new \PhpOffice\PhpWord\PhpWord();
$template = $phpword->loadTemplate( $docx_path );
$template->cloneBlock('Container-block', 2, true, true); //block contains lists
// Save the modified document
$new_docx_path = str_ireplace( ".docx", "_cloned.docx", $docx_path);
$template->saveAs($new_docx_path);
return $new_docx_path;
}
Sample Docx Result
BLOCK
1. Item 1
a) Subitem 1a
b) Subitem 1b
2. Item 2
a) Subitem 2a
BLOCK
1. Item 1
c) Subitem 1a
d) Subitem 1b
2. Item 2
b) Subitem 2a
BLOCK
1. Item 1
e) Subitem 1a
f) Subitem 1b
2. Item 2
c) Subitem 2a
Desired Solution:
I'm looking for guidance on how to reset the numbering in the inner lists inside the cloned block so that they start from the beginning. Any suggestions or code examples would be greatly appreciated.
BLOCK
1. Item 1
a) Subitem 1a
b) Subitem 1b
2. Item 2
a) Subitem 2a
BLOCK
1. Item 1
a) Subitem 1a
b) Subitem 1b
2. Item 2
a) Subitem 2a
BLOCK
1. Item 1
a) Subitem 1a
b) Subitem 1b
2. Item 2
a) Subitem 2a
The text was updated successfully, but these errors were encountered:
I concluded there is no /PHPWord way to do it, I implemented a custom and rough solution. I unfortunately don't have that code available at this moment.
I'm using the PHPWord library to clone a block containing a multilevel numbered list in a DOCX document. However, I've noticed that the numbering inner levels in the cloned block continues from the original block, which is not the behavior I'm looking for. I'd like to reset the numbering in lists inside the new block.
Steps to Reproduce:
Clone a block containing a multilevel numbered list using the cloneBlock method.
Observe that the numbering in the cloned block continues from the original block.
Expected Behavior:
I would like to reset the numbering in the lists inside the cloned block so that they start from the beginning (e.g., 1, 2, 3...).
Current Implementation:
Sample Docx Result
Desired Solution:
I'm looking for guidance on how to reset the numbering in the inner lists inside the cloned block so that they start from the beginning. Any suggestions or code examples would be greatly appreciated.
The text was updated successfully, but these errors were encountered: