$log->logLine("Add Chapter 7.1.2.0"); $book->backLevel(); $book->addChapter("Chapter 7.1.2", "Chapter007120.html", $content_start . "<h2>Chapter 7.1.2.0</h2>\n" . $chapter7Body, false, EPub::EXTERNAL_REF_ADD, $fileDir); $log->logLine("Add Chapter 7.1.3.0"); $book->addChapter("Chapter 7.1.3", "Chapter007130.html", $content_start . "<h2>Chapter 7.1.3.0</h2>\n" . $chapter7Body, false, EPub::EXTERNAL_REF_ADD, $fileDir); $log->logLine("Add Chapter 7.1.3.x"); $book->subLevel(); $book->addChapter("Chapter 7.1.3.1", "Chapter007131.html", $content_start . "<h2>Chapter 7.1.3.1</h2>\n" . $chapter7Body, false, EPub::EXTERNAL_REF_ADD, $fileDir); $book->addChapter("Chapter 7.1.3.2", "Chapter007132.html", $content_start . "<h2>Chapter 7.1.3.2</h2>\n" . $chapter7Body, false, EPub::EXTERNAL_REF_ADD, $fileDir); $book->addChapter("Chapter 7.1.3.3", "Chapter007133.html", $content_start . "<h2>Chapter 7.1.3.3</h2>\n" . $chapter7Body, false, EPub::EXTERNAL_REF_ADD, $fileDir); $book->addChapter("Chapter 7.1.3.4", "Chapter007134.html", $content_start . "<h2>Chapter 7.1.3.4</h2>\n" . $chapter7Body, false, EPub::EXTERNAL_REF_ADD, $fileDir); $log->logLine("Add Chapter 7.2.0.0"); // We went deep with Chapter 7.1.3.x, and sometimes the generating class knows exactly where it is anyway, // so instead of relying on multiple ->backLevel() calls, you can set the target level directly. // This only works for going back in the hieracy. ->setCurrentLevel(1) (or less) equals ->rootLevel(); $book->setCurrentLevel(2); $book->addChapter("Chapter 7.2", "Chapter00720.html", $content_start . "<h2>Chapter 7.2.0</h2>\n" . $chapter7Body, false, EPub::EXTERNAL_REF_ADD, $fileDir); $log->logLine("Add Chapter 7.3.0.0"); $book->addChapter("Chapter 7.3", "Chapter00730.html", $content_start . "<h2>Chapter 7.3.0</h2>\n" . $chapter7Body, false, EPub::EXTERNAL_REF_ADD, $fileDir); $log->logLine("Add Chapter 7.3.1.0"); $book->subLevel(); $book->addChapter("Chapter 7.3.1", "Chapter00731.html", $content_start . "<h2>Chapter 7.3.1</h2>\n" . $chapter7Body, false, EPub::EXTERNAL_REF_ADD, $fileDir); // If you have nested chapters, you can call ->rootLevel() to return your hierachy to the root of the navMap. $book->rootLevel(); $log->logLine("Add TOC"); $book->buildTOC(); $book->addChapter("Log", "Log.html", $content_start . $log->getLog() . "\n</pre>" . $bookEnd); if ($book->isLogging) { // Only used in case we need to debug EPub.php. $epuplog = $book->getLog(); $book->addChapter("ePubLog", "ePubLog.html", $content_start . $epuplog . "\n</pre>" . $bookEnd);