This website uses cookies to remember you and improve your experience. For more info see our Privacy Policy.

Mobile Menu

  • Menu
  • Skip to right header navigation
  • Skip to main content

Stormhill Media

Custom websites for every type of business

Header Right

  • About
  • Websites
    • Business Websites
    • Author Websites
  • SEO
  • Portfolio
  • Services & Pricing
    • Author Website Packages
    • Website Hosting
    • Page Speed Optimization
    • SEO
  • Plugins
    • MyBookTable
    • MyBookProgress
    • MySpeakingEvents
    • Plugin Support
  • Contact
  • Hire Us

Template System Overview

Home » Developer Resources » Template System Overview

The template files in the plugin under the templates folder contain the markup and template structure for the front-end of your MyBookTable pages. MyBookTable supports a way to edit these files in an upgrade safe way through overrides. Simply copy the template you want to override into a mybooktable directory within your theme, keeping the same file structure.

Example:
To overide the book archive header section, copy: wp-content/plugins/mybooktable/templates/archive-book/header.php to wp-content/themes/YOURTHEME/mybooktable/archive-book/header.php
The copied file will then override the MyBookTable default template file. Do not edit these files within the core plugin itself as they are overwritten during the upgrade process and any customization will be lost.

If you open these files you’ll notice they all contain many hooks which will allow you to add / move content without having to edit the template files themselves. This method protects even further against any upgrade issues as you can make modifications to how your books display by overriding these hooks and filters while leaving the the template files completely untouched. You can learn more about the hooks and filters you can use to override MyBookTable content on the Template Functions and Hooks page.

Book Display Mode System
With the advent of MyBookTable 3.0, the plugin now supports different Display Modes for single book pages. MyBookTable will look for a file named single-book-.php for the root template for the for that Display Mode. For example, for the storefront Display Mode, it will look for the file single-book-storefront.php. For a Display Mode to be valid, there must also be an action named mbt_single_book_<$display_mode>_content that will display all page content for the book then the action is run. This is used for things like properly rendering the shortcode for a book with a given Display Mode.

Book Sections System
With the advent of MyBookTable 3.0, the plugin now has the concept of “Book Sections” in order to allow for extensions to the way the book pages display in a more robust manner and to allow support for the Section Sorting system that allows users to re-order these sections to better suit their needs. Many features of book pages, such as the Book Reviews system, used to be included on the book pages using the mbt_after_single_book hook. This quickly grew unwieldy as new features were added. The new Book Sections system allows developers to add new sections more easily and for users to manage them better.
Single Book Display Mode templates should use the mbt_do_book_content_sections to display their book content, and then add the book sections they want to show to the appropriate Display Mode. Book Sections are associated with Display Modes with the mbt_get__content_sections filter.

Example:
The following example adds a new ‘My New Section’ section to the storefront Display Mode.
function mbt_add_content_section($sections) {
$sections[‘mynewsection’] = array(‘name’=> ‘My New Section’, ‘priority’ => 10, ‘action’ => ‘render_my_new_section’);
return $sections;
}
add_action(‘mbt_get_storefront_content_sections’, ‘mbt_add_content_section’);

The Book Sections are represented as an array with the following values:
name: The human-readable name for the section. This will be displayed by the Section Sorter interface.
priority: The default priority of the section, or how high on the book page it will display relative to other sections. This will be overridden by the Section Sorter interface if the user re-arranges the sections.
action OR function: The action or function that will be called when the template wants to display the section. There will be no parameters passed to the action or function, the section should look at the global $post variable for the book information.

« Previous
Next »

Site Footer

Quick Links:

  • Contact Us
  • Pricing & Services
  • Sitemap
  • Terms/Conditions
  • Privacy Policy
  • Business Websites
  • Author Websites
  • SEO Services
(903) 213-5266‬

Copyright © 2023 · Stormhill Media All Rights Reserved.
Website by Stormhill Media
Log in