More in this section

Forums / Developing with Sitefinity / Get VideoUrl in template

Get VideoUrl in template

6 posts, 0 answered
  1. Crusader
    Crusader avatar
    12 posts
    Registered:
    28 Oct 2009
    24 Nov 2009
    Link to this post
    Hi.
    I'm using Sitefinity 3.7. I have made video gallery and upload .flv video files. I'm using a flashPlayer to watch video in the videoGallery. I have added template for videoDetails page. How can i get videoUrl in my template?
    Thanks for all.
  2. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    24 Nov 2009
    Link to this post
    Hello Crusader,

    Are videos uploaded in the Sitefinity Libraries or stored on file system of your website? If they are in the Libraries on the video gallery page that displays all videos you can pass the item clicked ID in the query string when you request the details page. Then on the details page you will get the ID from query string and get the content item using the LibraryManager GetContent() method using the ID as an arguement. Then you can get the item url.

    If you are storing videos on file system you can pass the path in the query string and then get the path from there.

    Regards,
    Radoslav Georgiev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. Crusader
    Crusader avatar
    12 posts
    Registered:
    28 Oct 2009
    25 Nov 2009
    Link to this post
    Hello.
    All my videos uploaded in the Sitefinity Libraries of website. How can I add ID for all video in video list? How can I pass the item clicked ID in the query string? Can you describe more about this?

    Thanks
    Crusader
  4. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    25 Nov 2009
    Link to this post
    Hi Crusader,

    If you are just adding the flash player to the control template for the details view of the built in video control you can just take the URL from the intial parameters of the Silverlight player control. Note that you have to parse the string to get the url only. Initial parameters of the player are in the form: videoUrl={0},title={1},description={2}, so you should get the substring after videoUrl= and before ,title=. You can just add the page load event handler to the template:
    <script type="text/C#" runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            string parameters = playerHost.InitParameters;
             
         }      
        </script>

    If you are using custom controls can you show me their markup and code.

    Greetings,
    Radoslav Georgiev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  5. Crusader
    Crusader avatar
    12 posts
    Registered:
    28 Oct 2009
    25 Nov 2009
    Link to this post
    Your workaround is not acceptable because I want to completely remove Silverlight player, so there will be no playerHost control on the page. Any other suggestions?
  6. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    25 Nov 2009
    Link to this post
    Hi Crusader,

    You have at least 3 more options:
    1) Create your own controls to handle that.

    2) Bind to the ItemDataBound event of the repeater control that displays the list of items and add a hidden field to the ItemTemplate of the repeater to store the url for each content item. Then when you click an item you should add the value of the respective url to query string or view state. Here is sample how to populate the hidden field in the control template for displaying list of videos:
    <script type="text/C#" runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            repeater.ItemDataBound += new RepeaterItemEventHandler(repeater_ItemDataBound);
        }
     
        void repeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
             if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
             {
                Telerik.Cms.Engine.IContent cnt = (Telerik.Cms.Engine.IContent)e.Item.DataItem;
                Guid itemID = cnt.ID;
                string itemUrl = cnt.UrlWithExtension;
                HiddenField urlHidden = (HiddenField)e.Item.FindControl("url");
                urlHidden.Value = itemUrl;           
             }
        }
        </script>
    <asp:HyperLink ID="backLink" runat="server" Text="<%$Resources:Videos_GoBack %>" />
     
     <asp:Panel ID="noItem" runat="server" style="color:Red;" Visible="false">
        <asp:Literal ID="Literal5" runat="server" Text="<%$Resources:Videos_NoVideo %>" />
     </asp:Panel>
    <asp:Repeater ID="repeater" runat="server">
        <HeaderTemplate><ul class="sf_videoList"></HeaderTemplate>
       <ItemTemplate>
            <li>
                <asp:HiddenField runat="server" ID="url" />
         ...

    3) You can use the Library manager on the details template to use the Library manager to filter library items by metafiled values that are displayed on the page and get the content item:
    <script type="text/C#" runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            //string parameters = playerHost.InitParameters;
            Telerik.Libraries.LibraryManager libManager = new Telerik.Libraries.LibraryManager();
            //filter by metafields to get the content item
            System.Collections.Generic.List<Telerik.Cms.Engine.IMetaSearchInfo> filters = new System.Collections.Generic.List<Telerik.Cms.Engine.IMetaSearchInfo>();
            filters.Add(new Telerik.Cms.Engine.MetaSearchInfo(Telerik.Cms.Engine.MetaValueTypes.ShortText, "Name", this.Title.Text, Telerik.Cms.Engine.SearchCondition.Equal, Telerik.Cms.Engine.JoinType.And));
            filters.Add(new Telerik.Cms.Engine.MetaSearchInfo(Telerik.Cms.Engine.MetaValueTypes.ShortText, "Description", this.Description.Text, Telerik.Cms.Engine.SearchCondition.Equal, Telerik.Cms.Engine.JoinType.And));
            IList filtered = libManager.GetContent(filters.ToArray());
            Telerik.Cms.Engine.IContent cnt = filtered[0] as Telerik.Cms.Engine.IContent;
            string url = cnt.UrlWithExtension;
         }      
        </script>


    I thing that all of the above methods are either more clunky or will require more time to perfect than simply setting the silverlight control not to be visible.

    Greetings,
    Radoslav Georgiev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Register for webinar
6 posts, 0 answered