• Resolved sagalbot

    (@sagalbot)


    I was previously using tags to embed videos, and simple conditionals. Users had to fill out a form, which embedded a cookie, and then the videos become available. If the embed-video tag was present, the forms were included. If the cookie was already present, the forms are skipped and the video is included. Now I’d like to upgrade to custom shortcode.

    Here’s what I’ve got so far.

    [Code moderated as per the Forum Rules. Please use the pastebin]

    All of this code works. The issue is that while the video embeds at the proper location within the post, the forms show up at the top of the post no matter what.

    This is because I use return to embed the video and include to embed the forms. There’s lots of conditionals and validation directly within the included forms, so as far as I know, I can’t wrap it all in a variable and return it.

    Is there another way I can continue to use includes, but have the forms show up at the same spot as the video player?

    I hope this makes at least partial sense. Any input is greatly appreciated.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Anonymous User

    (@anonymized-3085)

    No you need to return what needs printing to the screen otherwise you will get exactly what you describe – the form printing before the main content.

    There’s lots of conditionals and validation directly within the included forms,

    then it may need a bit of work to adapt.

    Thread Starter sagalbot

    (@sagalbot)

    Sorry about the code snippet, just read the rules regarding Code.

    Thanks for the reply. Adaptation it is.

    Thread Starter sagalbot

    (@sagalbot)

    FYI, I came up with a solution that didn’t require me to rewrite any code. Using:

    ob_start();
    include TEMPLATEPATH . '/assets/inc/forms/basic.php';
    $content = ob_get_clean();
    return $content;

    I was able to assign the included page to a variable. Yeehaw!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Custom Shortcodes, Includes, and Return.’ is closed to new replies.