WordPress.org

Ready to get started?Download WordPress

Forums

Google Doc Embedder
Is there a documented API for low-level interaction with this plugin? (3 posts)

  1. Dan Rossiter
    Member
    Posted 2 years ago #

    I'm working on a theme that will eventually integrate this plugin as part of its core functionality. In order to achieve a lot of the goals in the design, I need to be able to access things like changing the current page of a document without the user directly interacting with the viewer or programmatically detect the number of pages in a given document on page load. (Those are just a couple of things I would need to access off the top of my head.) Obviously I can control the page that the viewer starts on at load time with the new version release page specifier, but that still doesn't allow for changing the page after load short of reloading the document with the page value changed.

    I've started to dig down into the source, but I was wondering if there might be documentation for this kind of interaction with the plugin somewhere. I've looked through the plugin site and information on WordPress, but haven't found anything deeper than the "Advanced Options," which don't really go deep enough for my needs.

    PS: This really is a fantastic plugin. Thanks for putting all the time into making it so useful to the WordPress community!

    http://wordpress.org/extend/plugins/google-document-embedder/

  2. k3davis
    Member
    Plugin Author

    Posted 2 years ago #

    Dan,

    I'm very interested to see what you accomplish in integrating this plugin with your theme. Fortunately/unfortunately, I have mixed news to report on your request.

    In the first place, while I've never tried it, I expect it's possible to control the page changing from outside the viewer frame. Jumping to a specific page is handled by Javascript after that portion of the viewer has loaded. Skipping to page 2, for example, is accomplished by added this onload event to the iframe itself:

    onload="javascript:this.contentWindow.location.hash=':0.page.1';"

    (Note that the pages are indexed from 0, so to get to page 6, you'll have to put page.5 on the end, etc.) You would have to try to fire this behavior using some external link or button instead of the onload event - again I've never tried this but it's somewhat hopeful. ;)

    As far as counting the number of pages, this is much more difficult, only because the viewer loads the pages one at a time to decrease time to actually display the first page. I've written some functions that do provide a page count, but they are costly in that they have to essentially load the entire document first and then count the pages. This can have pretty severe performance disadvantages, especially for longer or larger docs. I would consider this probably not useful at present.

    Let me know if you have other ideas/questions, and thanks so much for your positive feedback about the plugin! Looking forward to developing it further. 2.5 was a monumental release so I expect I'll need a couple maintenance releases to make it rock solid like 2.4.6 was, before starting to add significant new features again.

    Kevin

  3. Dan Rossiter
    Member
    Posted 2 years ago #

    Thanks so much for the quick and informative response!

    The page skipping does sound very doable. Sounds like it's basically a question of listening for the necessary page to load, then enabling the page skip once it's loaded.

    With the page count, it sounds like the best option would be to store the count in a local database so it's not causing a massive hang for the end user. If a priming plugin run is built into how I implement the theme then the one slow run will be absorbed during upload and the end user doesn't need to deal with that.

    Let me play around with some of this and see where I get.

    Thanks again for the information and the fantastic plugin! I look forward to your future releases!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags