3D FlipBook - How to create book template in v1.14, filter

b***l@gmail.com
2023-01-17
2024-02-05

Hi,

I love this new update, this was exactly what I was looking for! But how can I create a new book template? I don’t see any option and there’s any mention in the documentation.

Best regards.

Replies

b***l@gmail.com
2023-01-17
2023-01-17

I just see this reference in "Settings": https://i.gyazo.com/814dbd0ae69f682ff69bb8beb3ffbbfd.png but I can't find the "Book templates" section anywhere.

Thanks!

a***r@3dflipbook.net
2023-01-17
2023-01-17

Edit any book, check shows advanced options. In the end of General tab: Save this book as Template. It does not affect on pages and bookmarks, because they are different for all books.

b***l@gmail.com
2023-01-17
2023-01-17

Hi, That was helpful :) I saved a book as a template, and then I used in the shortcode as you said on the release notes, like this: [3d-flip-book pdf="http://mysite.com/sample.pdf" book-template="Journal"][/3d-flip-book] The issue is that I don't see the elements saved on my book in the new PDF url. For example, I added a image on page 1 in the original book/template, but now If I use a template, I see my new PDF but can't see that image in the first page. How can I do that? Thanks!

a***r@3dflipbook.net
2023-01-17
2023-01-17

Templates do not affects on pages, function what you need is a little different, we cannot understand how to create template for set of pages, because all books have different pages amount and their content. So please describe your case that we could figure out how we can help you.

b***l@gmail.com
2023-01-17
2023-01-17

Hi again,

Sure, let me explain:

  • I want to create a template with some custom content in each page (like images, HTML...).
  • Then, I want to dynamically show different custom PDF based on order checkout
  • That PDF would be displayed in the 3D books, but I would like to keep the images and HTML in the same place and page for all the PDF with the same template name.

So basically, I'd like to have a template with custom content and let me applied that template in different PDF. And about "not every PDF have the same pages", in my case it does, but even if it isn't the case, the template could just applied the custom content (images, HTML...) just in the pages that the PDF have.

I hope that I had explain my self a little bit better.

Best regards.

a***r@3dflipbook.net
2023-01-19
2023-01-19

Well, in this case the easiest way is create a filter for book data and simply replace pdf URL with that what you need. You will need to add some php code (filtering function) in your theme functions file, and we will add this filter in out plugins API.

b***l@gmail.com
2023-01-19
2023-01-19

Hi, I actually have the code to replace the PDF url, so no problem about that, but how can I do the other stuff? Can you help me with this custom work? If have an email address, I can give you more details. Thanks a lot!

a***r@3dflipbook.net
2023-01-19
2023-01-19

I would recommend to add in your theme functions something like this

  
  $flipbook_filter = [
    'active'=> false
  ];
  function flipbook_post_filter($post) {
    global $flipbook_filter;
    if($flipbook_filter['active']) {
      $post['data']['guid'] = $flipbook_filter['pdf'];
      $post['data']['pdf_pages'] = is_null($flipbook_filter['pages'])? $post['data']['pdf_pages']: $flipbook_filter['pages'];
    }
    return $post;
  }

  add_filter('fb3d_post', 'flipbook_post_filter');

  function flipbook_filter_shortcode_handler($atts, $content) {
    global $flipbook_filter;
    $atts = shortcode_atts([
      'pdf'=> '',
      'pages'=> null
    ], $atts);
    $flipbook_filter = [
      'active'=> true,
      'pdf'=> $atts['pdf'],
      'pages'=> $atts['pages']
    ];
    $res = do_shortcode($content);
    $flipbook_filter['active'] = false;
    return $res;
  }

  add_shortcode('3d-flip-book-filter', 'flipbook_filter_shortcode_handler');

and then simply use it like this:

[3d-flip-book-filter pdf="http://wordpress/wp-content/uploads/2022/12/franchise_no.15.pdf" pages="52"][3d-flip-book mode="fullscreen" id="2236"][/3d-flip-book][/3d-flip-book-filter]

also you need to add filter call in the plugin file ajax-get.php

  function post_to_user_post($post, $isMeta) {
//...
    return apply_filters('fb3d_post', [
      'ID'=> $post->ID,
//...
      'post_type'=> $post->post_type
    ]);
  }

we already added this filter in our code, but will publish it in next release, so you can easily update the plugin in the future.

b***l@gmail.com
2023-01-19
2023-01-19

Hi,

What an amazing support! Really happy with the plugin and the feedback.

About the code, would be necessary to add the functions.php code also if I wait until new update?

Thanks!

a***r@3dflipbook.net
2023-01-19
2023-01-19

Yes you need to do this. This case is quite specific so we are not planning to add it for all.

b***l@gmail.com
2024-02-19
2024-02-19

Hi, so I added the code you gave in functions.php and use the shortcode [3d-flip-book-filter pdf="xxxxx.pdf" pages="52"][3d-flip-book mode="fullscreen" id="XXXX"][/3d-flip-book][/3d-flip-book-filter] and replaced the ID for my own one, but unfortunately the external PDF url it isn't being displayed. It is being displayed the default PDF uploaded in the template... so what's the issue? Thanks!

Log In to leave a comment