Forum Discussion

lakshmir's avatar
lakshmir
Helper
12 years ago

How to embed different YouTube videos to separate discussion forums?

Hi there,

 

I want to embed various YouTube videos to separate discussion forums. Clicking of the image should open up a modal dialog which should play the video. Can this be achieved using the standard "video" component or should I create a customised component? Please see the attached image files that I am trying to achieve.

 

I have to update with the same video for various forum URLs which has same pageName, in some cases it has different pagenames. Any guidance in this would be much appreciated. Thanks.

 

Regards,

Laks


hyperlink-image.jpgpop-up-image.jpg
  • AdamN's avatar
    AdamN
    12 years ago

    Hi Laks,

     

    Assuming you're placing the custom component on the Forum Page, you shouldn't need to do anything with the URL. Instead, you can take advantage of how custom content modules work. In the first option I laid out, a custom content module was to be used for storing the vidoe URL (or video ID if that's how you'd prefer to do it).

     

    So let's say for example that you're going to use Custom Content 9 for storing your video ID. Each node of the community (the community level, each category, each board) has its own version of Custom Content 9 associated with it. If you add content for Custom Content 9 at the community level, then it sets the default for the lower levels. Similarly, if you add custom content at the category level, it sets the default for those nodes within that category. But you can still override that for individual boards and at whatever content you'd like for each board.

     

    So let's start with Board ABC:

    1. Browse to the Community Admin
    2. Select to manage Board ABC
    3. Select the Content tab, and then Custom Content
    4. From the drop down, select Custom Content 9
    5. Within the Custom Content 9 Text, enter the video ID for the video, (ie. "dQw4w9WgXcQ")

    Then you can repeat for Board DEF, Board GHI, and so on...

     

    Then, back in your custom component where you've added the code for your video modal/player, you'll need to get the video ID associated with the Forum Page that the component is rendering on. In my last post, I mentioned that the values of the Custom Content modules are stored as settings for each node. And in this case, you'll want to get the setting named customcontent.9_text. So you should be able to do something like this to get the video id:

    ${coreNode.settings.name.get("customcontent.9_text")}

    So if your component is rendering on Board ABC, it's going to grab the value set in the admin for Custom Content 9 for Board ABC. If your component is rendering on Board DEF, it's going to grab the value set in the admin for Custom Content 9 for Board DEF. And so on...

     

    Does that make sense? Let me know if you need more details.

  • AdamN's avatar
    AdamN
    Khoros Oracle

    There's no standard component for what you want to do, but it should be possible through customization.

     

    If you want the videos to be different for each forum, you have a couple of options, but both involve the use of custom content modules via the Community Admin. The benefit of a custom content module is that you can update it at any time (ie. you don't have to wait for a Studio push) and you can also set different content per node of the community. The approach I'd reccomend depends on how common your code will be.

     

    If the player code and surrounding markup will be the same for each forum and only the video URL will change, then you could benefit from using a custom component as well. Here's how that would work:

    • Designate a custom content module that will be used to store the URL for the video and populate the content for each forum. The content of this custom content module is stored as a setting for the forum.
    • Create a custom component in Studio that will store the common code for the player and the related markup.
    • Within the custom component where you need to insert the URL of the video, you can retreive the value of the custom content module (the Video URL in this case) using the settings context object, for example (assuming you stored the value in body of Custom Content 1): ${settings.name.get("customcontent.1_text")}
    • Add the custom component to the Forum Page in Studio

    If the player code is not the same for each forum, then you can just use a custom content module by itself:

    • Designate a custom content module that will be used to store the code for the video and populate the content for each forum.
    • Using Studio, place the custom content module on the Forum Page.


    The first approach is nice if the player code will be common. That way you don't have to duplicate the code and worry about having to update it each time the code changes. You'd only have to worry about changing the URLs for the videos as needed. The second approach is definitely the easier and more straight-forward approach, but also carries with it the baggage of more long-term maintenance. If you need more details about either of these approaches, let me know.

     

    I hope this helps!

    • lakshmir's avatar
      lakshmir
      Helper

      Hi Adam,

       

      Thanks for your time and guidance. I am going with the first option as you suggested as my player code is the same. I have to put different youtube video on different pages. I am trying to create one custom component for the video player, which I will be embedding on all the needed page templates.

       

      I am creating a custom text for different videoIDs to be used as the variable in the custom video player component.

       

      I need to place different videoID for different page url, but has reference to same page template. How to find the different page? can I use some method to find the url of the page? so that I can associate the needed videoID on that page. Currently, I have a logic to find the current url and use the appropriate VideoID variable. But having difficulty to get the current page url. I managed to get the domain level (through ${page.content.nav.breadcrumb.crumbs[0].url} )  but not the full url. Need help, thanks.

       

      Thanks again,

      Laks

      • AdamN's avatar
        AdamN
        Khoros Oracle

        Hi Laks,

         

        Assuming you're placing the custom component on the Forum Page, you shouldn't need to do anything with the URL. Instead, you can take advantage of how custom content modules work. In the first option I laid out, a custom content module was to be used for storing the vidoe URL (or video ID if that's how you'd prefer to do it).

         

        So let's say for example that you're going to use Custom Content 9 for storing your video ID. Each node of the community (the community level, each category, each board) has its own version of Custom Content 9 associated with it. If you add content for Custom Content 9 at the community level, then it sets the default for the lower levels. Similarly, if you add custom content at the category level, it sets the default for those nodes within that category. But you can still override that for individual boards and at whatever content you'd like for each board.

         

        So let's start with Board ABC:

        1. Browse to the Community Admin
        2. Select to manage Board ABC
        3. Select the Content tab, and then Custom Content
        4. From the drop down, select Custom Content 9
        5. Within the Custom Content 9 Text, enter the video ID for the video, (ie. "dQw4w9WgXcQ")

        Then you can repeat for Board DEF, Board GHI, and so on...

         

        Then, back in your custom component where you've added the code for your video modal/player, you'll need to get the video ID associated with the Forum Page that the component is rendering on. In my last post, I mentioned that the values of the Custom Content modules are stored as settings for each node. And in this case, you'll want to get the setting named customcontent.9_text. So you should be able to do something like this to get the video id:

        ${coreNode.settings.name.get("customcontent.9_text")}

        So if your component is rendering on Board ABC, it's going to grab the value set in the admin for Custom Content 9 for Board ABC. If your component is rendering on Board DEF, it's going to grab the value set in the admin for Custom Content 9 for Board DEF. And so on...

         

        Does that make sense? Let me know if you need more details.