In phpWord, I would like to modify the text that appears on the Table of Contents to be different from what appears in the individual section titles.
// Add title styles
$phpWord->addTitleStyle(1,[],[]);
// Add TOC
$toc = $section->addTOC();
//Section 0
$section = $phpWord->addSection();
$section->addTitle('Section 00', 1);
//Section 1
$section = $phpWord->addSection();
$section->addTitle('Section 01', 1);
//Section 2
$section = $phpWord->addSection();
$section->addTitle('Section 02', 1);
This will produce a Table of Contents that looks like this:
Section 00......................2
Section 01......................3
Section 02......................4
Is there a way to make the text on the Table of Contents display something different from the text that is printed in the actual sections?
What I want:
Section 00.............................2
Section 01 (Not Applicable)............3
Section 02 (Will be submitted Later)...4
I still want the sections of the document to have the titles Section 00, Section 01, Section 02; but I want to be able to modify the text that appears in the TOC.
Is that possible?
What I'm hoping is that something like the line below exists, but I can't find anything like that in the documentation.
$section->addTitle('Section 01', 1,['altext' => 'Section 01 (Not Applicable)']);