Viewing 5 replies - 1 through 5 (of 5 total)
  • Hello David,

    Usually you don’t need to use the do_shortcode method, but I will trust you know what you’re doing. 😉 However please just use the standard GDE shortcode inside the command. I seee you have parenthesis around the file= attribute and its value, and this shouldn’t be necessary.

    Hope this helps.

    Kevin

    Thread Starter DavidSadler

    (@davidsadler)

    Thanks Kevin for responding. I’m afraid I didn’t do a good job asking my question.

    If I need to bring up gview in a new page for each different document I want to show, how is the best way to do that? I was thinking of having a “Doc View” page that is called with a file name. Then in the Doc View page would the correct code be this –

    [insert_php]
    echo do_shortcode(‘[gview(file=’. $_REQUEST[‘f’] .’)]’);
    [/insert_php]

    Or, is there a way to call gview in-line using a short code where it launches in a new window – [gview(file=2014/09/Sustainability-Flyer-Draft.docx)], target=”viewer”)] ?

    Thanks again

    Hey David, I’ll be honest I’ve never tried the method you’re attempting here so I don’t have a ready guaranteed fix, but I’m still puzzled by the parenthesis you’re using… does it not work with something like the below?

    echo do_shortcode('[gview file="'. $_REQUEST['f'] .'"]');

    Meaning, wrap your do_shortcode command in parenthesis but not the shortcode attributes themselves. If you’re getting the value of ‘f’ from the query string you may also have to urldecode it first:

    echo do_shortcode('[gview file="'. urldecode($_REQUEST['f']) .'"]');

    You may have to experiment with just echoing the shortcode itself to the page to make sure it’s rendering correctly in the page source before wrapping it in do_shortcode, just to try to pinpoint the source of the problem. In the page source this:

    echo '[[gview file="'. urldecode($_REQUEST['f']) .'"]]');

    should look like this:

    [[gview file="http://whateverurl.com/doc.pdf"]]

    without any special characters (denoted by % signs and numbers), HTML, PHP messages, or other junk. (Note the double bracket thing [[…]] is probably optional in this case but can be used within the wordpress “loop” to show the shortcode on the page instead of actually rendering its results.)

    GDE is an embedded viewer (hence its [poorly chosen] name) so it wouldn’t make sense for it to automatically open another window based on the shortcode, but you can of course make the link to the page you’re creating open in a new window using target=, or set the default profile of the full screen button to open in a new window when they enlarge the viewer, etc.

    If that doesn’t get you anywhere let me know where it does get you and I’ll see if I can come up with any other suggestions.

    Best of luck,

    Kevin

    Thread Starter DavidSadler

    (@davidsadler)

    Thanks again Kevin for helping. These versions yielded no errors and a blank page –

    echo do_shortcode(‘[gview(file=”‘. $_REQUEST[‘f’] .'”)]’); (quotes around the variable)
    echo do_shortcode(‘[gview(file=”‘. urldecode($_REQUEST[‘f’]) .'”)]’);

    Then I tried – echo ‘[[gview file=”‘. urldecode($_REQUEST[‘f’]) .'”]]’); and it yielded the correct code. Then I went back to the origial – echo do_shortcode(‘[gview(file=”‘. urldecode($_REQUEST[‘f’]) .'”)]’); which yielded a no errors and a blank screen. Then I used the browser de-bugger to inspect the code sent to the page and bingo. The code is encapsulated with <p>…</p>.

    I said I’m a newbie when it comes to WP. What would be the correct way to disable the the auto encoding?

    What does this code do?

    echo do_shortcode('[gview file="'. urldecode($_REQUEST['f']) .'"]');

    or alternately

    $sc = ‘[gview file=”‘. urldecode($_REQUEST[‘f’]) .'”]’;
    echo do_shortcode($sc);

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘gview called using do_shortcode’ is closed to new replies.