Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Embed opens specific category or topic?

FlipstyleFlipstyle New
edited May 2011 in Vanilla 2.0 - 2.8
I'd like to embed a specific category or topic on a page. Is there a different embed code or option?

For example when a user opens up a page on my blog the embed will open General Discussion Category and topic #1 for example.

Comments

  • I was able to make a link were the user clicks on to show all the threads. Is there any code mods?
  • Been trying to figure this out myself for embedding the Boxes and Text community forum directly into the Alpha webapp.
    http://forum.boxesandtext.com
    http://alpha.boxesandtext.com

    Looks like there are two ways: 1. modify the URL hash when the user loads the page, or 2. set javascript variables before loading the embed code.

    First, load the page you want and check out the URL. For way 1, copy everything that comes after ?p=________. For way 2, you'll need to somehow get discussion id, foreign_id, etc... May take some digging.

    In short, the simplest way is go set window.location.hash before you load the embed script.

    EXAMPLE:

    <div style="">
    <script>
    // WAY 1: set the URL hash on document load...
    window.location.hash = "/categories/general";

    // WAY 2: set javascript variables before loading the embed javascript...
    // What type of embed are we performing?
    //vanilla_embed_type = "standard";
    // Are we loading a particular discussion based on discussion_id?
    //vanilla_discussion_id = "";
    // Are we loading a particular discussion based on foreign_id?
    //vanilla_foreign_id = "";
    // Is there a foreign type defined? Possibly used to render the discussion
    // body a certain way in the forum? Also used to filter down to foreign
    // types so that matching foreign_id's across type don't clash.
    //vanilla_foreign_type = "";
    // If embedding comments, should the newly created discussion be placed in a specific category?
    //vanilla_category_id = "dev-circle";
    // If embedding comments, this value will be used as the newly created discussion title.
    //vanilla_foreign_name = "";
    // If embedding comments, this value will be used to reference the foreign content. Defaults to the url of the page this file is included in.
    //vanilla_foreign_url = document.URL;
    // If embedding comments, this value will be used as the first comment body related to the discussion
    //vanilla_foreign_body = "";
    </script>
    <script type="text/javascript" src="http://embed.vanillaforums.com/plugins/embedvanilla/remote.js"></script>
    </div>
  • FlipstyleFlipstyle New
    edited May 2011
    Hi,

    Thank you Akumpf for the reply. This is exactly what I been looking for a while now and works perfectly! I tried Way 1 and its very simple to use. I have a question about way 2. If I was to use way 2, I see there are more options but what exactly does it do compared to way 1?

    Anyways thanks so much for the code!
  • No too sure about way 2 myself. I reverse engineered it from the embed javascript source. I think it's included for some of the 3rd party vanilla forum embed widgets (like Wordpress), but it seems hardcoded to handle comments so it may not behave exactly as expected.

    For now, I'm sticking with way 1 (setting window.location.hash before embedding).
  • edited June 2014

    I get an error: "Code corrupted. Insert fresh copy."

    I added:
    <div style=""> <script> window.location.hash = "#/post/discussion"; </script> <script type="text/javascript" src="http://<sub>.<domain>/js/embed.js></script> </div>

    There must be some additional thing that I'm missing.

  • peregrineperegrine MVP
    edited June 2014

    @michaelmross

    3 problems I see.

    • you are necroposting on an old discussion
    • you failed to mention you version number of vanilla or what you are trying to accomplish
    • this plugin has been deprecated.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

Sign In or Register to comment.