Issues with custom theme and Pressbooks 5

From @kirkj:

We have been using Pressbooks and developed a custom theme with it. We followed the documentation creating the scaffolding and building from there, but when we upgraded to 5 and followed the upgrade instructions the styles to our front page are no longer loaded. It looks like on read pages the compiled stylesheet now stored in the new pressbooks folder in the uploads directory gets called, but not on the front page. Also it looks like some of the icons like the eyeball for increasing reading size as well as the javascript file for toc.js is no longer being loaded. We also see some various errors in the book.js file. Is there a web page that talks about any new styling caveats that are present with this new release of Pressbooks? If not can anyone help point me in the direction of what we would need to get the styles also called on the front page of the book?

Hi @kirkj,

The custom styles in your theme as per the tutorial are for book content, not the webbook cover page, so the fact that they only load on reading pages is expected. If you want to create styles that modify the cover page display, your best bet is to create a separate stylesheet and enqueue it in functions.php in a conditional function, e.g.

function custom_book_cover_styles() {
  if ( is_front_page() ) { // Only load this stylesheet on the book cover
    wp_enqueue_style( 'custom-book-cover', get_stylesheet_directory_uri() . '/styles/custom-book-cover.css', false, null );
  }
}

add_action( 'wp_enqueue_scripts', 'custom_book_theme_cover_styles' );

In terms of your other questions:

  1. The reading size control is at the top now (and has a textual label instead of just an icon):

07 PM

  1. The toc.js file is no longer used; all JavaScript needed for the book UI is loaded in /pressbooks-book/dist/styles/book.js.

In terms of other errors, are you using the latest version (2.1.0) of McLuhan, the parent book theme? Hope this helps, and thanks for letting us know about the problems you’ve found. I need to put some more documentation together covering the new book theme(s) so this is valuable feedback, as I’m sure others have encountered or will encounter similar issues.

Is that a situation for Github Pressbooks snippets ??

I could write something as example.

Hi Ned,
I would like to change the default cover of the book or add a second image there, what changes should be done in the files of my theme?
I tried what you wrote about the functions.php, but I didn’t know what to write in the css (I can’t change img.src in a css file)

Thanks a lot!
Etna

You do this in the Book Information page on your book’s dashboard. This doesn’t require additional code. See here, scroll down to the section titled “Cover”.

Hi! thanks for your help.
I would like to change the default cover page for all the users that use my website.
Is it possible doing it generally, without the need to change each book separately?

Thank you very much
Etna

if is about the image, yes, if is about a child theme, each book that use the theme would share the design.

So, where in the code (in the files) I should change the src of the cover image?

Thanks

No, that wouldn’t work. The cover image is used throughout Pressbooks in various ways, so you can’t just change it in the theme and expect it to work.

I’ve added a filter which will allow you to change the default cover image from a custom plugin or mu-plugin. It will be included in a forthcoming Pressbooks release (5.4). See here.

Thank you so much!
You are the best :grinning: