Closed tcitworld closed 8 years ago
How are you adding chapters?
Because, at a glance I don't see a way addChapter can do that, meaning you are obviously doing something I didn't anticipate (or overlooked). :P I'm not saying you are wrong, as you obviously have the problem.
The cover is added by this line :
$book->addChapter('Notices', 'Cover2.html', $content_start.$this->getExportInformation('PHPePub').$bookEnd);
and the chapters are added through a loop :
foreach ($this->entries as $entry) {
foreach ($this->tags as $tag) {
$book->setSubject($tag['value']);
}
$chapter = $content_start.$entry->getContent().$bookEnd;
$book->addChapter($entry->getTitle(), htmlspecialchars($entry->getTitle()).'.html', $chapter, true, EPub::EXTERNAL_REF_ADD);
}
Can I get you to send me an example of a defective book to php@grandt.com?
Boy, does that bug make me look "stoopid"
In addChapter I increase chapterCount. That function calls a few others of course, in the course of which the code checks if the book has been initialized yet, if it haven't is does so. Initialize Sets up the zip file and adding the preliminary metadata depending on the setup of the book. For instance the ePub version. And that initialization sets chapterCount to 0, AFTER I just increased it to 1...
I need more coffee.
P.S.: For a minimum impact of your current code, at least until I'm ready to release 4.0.6, you can just uncomment the $this->chapterCount = 0;
line in the initialize
function.
No worries. Thanks for your time.
For a minimum impact of your current code, at least until I'm ready to release 4.0.6
If we can get it through composer before end of March, it's perfectly fine. :)
I need to test 4.0.6 a little more, it's on github master branch now, but I expect to release it before the end of February.
On 21-02-2016 15:44, Thomas Citharel wrote:
No worries. Thanks for your time.
For a minimum impact of your current code, at least until I'm ready to release 4.0.6
If we can get it through composer before end of March, it's perfectly fine. :)
— Reply to this email directly or view it on GitHub https://github.com/Grandt/PHPePub/issues/36#issuecomment-186834027.
Perfect !
Hello @Grandt!
Do you plan to release a new version in next days?
Hi,
wallabag uses PHPePub to produce epubs from articles.
We first add a custom cover as a chapter, then we're looping around our entries to produce a chapter for each entry. However, it seems the produced epub has it's first two chapters with the same id (1) in the book.opf file. Therefore, our first entry isn't shown since it has the same id as our cover.
A workaround is to set
$this->chapterCount
to 1, but I can't get to understand why this happens.