1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Image associated with content item

Image associated with content item

6 posts, 0 answered
  1. Rick
    Rick avatar
    29 posts
    Registered:
    28 Oct 2009
    01 Feb 2010
    Link to this post
    Hi,

    I have implemented a buttonSelector control for my custom module from How to associate content items with files.
    It works perfect and gets [Provider]Guid value for selected image.
    However, in the preview page it does not show selected image.
    It rather shows the Guid value in the details. (refer to attached file)

    Is there a way to show the actual image?

    thanks,
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    01 Feb 2010
    Link to this post
    Hi Rick,

    The actual value of the metakey is [Provider]Guid and this is what the preview mode shows. You can modify the preview mode of the module you have created, read and resolve this meta key and set the result which will be a link to an Image control.

    Greetings,
    Ivan Dimitrov
    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. Rick
    Rick avatar
    29 posts
    Registered:
    28 Oct 2009
    02 Feb 2010
    Link to this post

    Hi Ivan,

    Thanks for the reply.
    I added Image control to Preview user control page.
    I got Provider name and Guid value, then resolved using resolve the dynamic url post.

    However, I have no idea how to link resolved url to Image control I added.
    I am mapping views with embedded templates. (The way Sample Product Module is using)

    PhotoCompPreviewView.cs

    protected override void ShowMetaData(Telerik.Cms.Engine.IContent stg, object dataSource)  
            {  
                base.ShowMetaData(stg, dataSource);  
     
                //Dictionary<object, object> test = (Dictionary<object, object>)dataSource;  
                string url = "";  
                foreach (var data in ((Dictionary<object, object>)dataSource))  
                {  
                    if (data.Key.ToString() == "Image")  
                    {  
                        url = data.Value.ToString();  
                        break;  
                    }  
                }  
     
                //var a = url.Split(new char[] { ' ' });  
                var providerName = url.Substring(1, 9);  
                var imageID = url.Substring(11);  
                  
                //string resolvedURL = LinkParser.ResolveLinks(url, this.GetItemUrl);  
                string resolvedURL = GetItemUrl(providerName, new Guid(imageID), true);  
                  
            }  
     
            public string GetItemUrl(string provider, Guid id, bool resolveAsAbsoluteUrl)  
            {  
                if (ContentManager.Providers.ContainsKey(provider))  
                {  
                    IContent cnt = ContentManager.Providers[provider].GetContent(id);  
                    if (cnt != null)  
                        return VirtualPathUtility.ToAbsolute(cnt.UrlWithExtension, this.Context.Request.ApplicationPath);  
                }  
                else  
                {  
                    // we assume it is a page    
                    SiteMapNode node = SiteMap.Provider.FindSiteMapNodeFromKey(id.ToString());  
                    if (node != null)  
                        return this.ResolveClientUrl(node.Url);  
                }  
                return String.Concat("Item not found: [", provider, "]", id);  
            }   

    PhotoCompPreviewView.ascx

    <%@ Control Language="C#" %> 
    <%@ Register TagPrefix="telerik" Namespace="Telerik.Workflow.WebControls" Assembly="Telerik.Workflow" %> 
    <%@ Register TagPrefix="telerik" Namespace="Telerik.Cms.Engine.WebControls" Assembly="Telerik.Cms.Engine" %> 
    <%@ Register TagPrefix="telerik" Namespace="Telerik.Localization.WebControls" Assembly="Telerik.Localization" %> 
    <div class="ToolsAll">  
        <asp:Label ID="lockedWarning" runat="server">  
            <class="locked">  
                <strong>{0}</strong>   
                <asp:Literal ID="Literal1" runat="server" Text="<%$Resources:IsEditingPhotoCompEntry %>"></asp:Literal> 
            </p> 
        </asp:Label> 
        <div class="backWrapp">  
            <asp:HyperLink ID="BackButton1" CssClass="actions back" runat="server">  
                <asp:Literal ID="Literal2" Text="<%$Resources:BackToAllPhotoCompEntries %>" runat="server" /> 
            </asp:HyperLink> 
        </div> 
        <telerik:RadTabStrip   
                        id="tabStrip"   
                        Align="Right"   
                        runat="server" 
                        selectedindex="0"   
                        causesvalidation="false" 
                        EnableEmbeddedSkins="false" 
                        Skin="SitefinityPages">  
                            <Tabs> 
                                <telerik:RadTab Text="<%$Resources:View %>" ></telerik:RadTab> 
                                <telerik:RadTab Text="<%$Resources:Edit %>" ></telerik:RadTab> 
                                <telerik:RadTab Text="<%$Resources:History %>" ></telerik:RadTab> 
                            </Tabs> 
                        </telerik:RadTabStrip> 
        <div class="clear"><!-- --></div>  
    </div> 
    <div id="divWorkArea" runat="server" class="workArea">  
        <telerik:MessageControl runat="server" ID="message1">  
            <ItemTemplate> 
                <asp:Label runat="server" ID="messageText"></asp:Label> 
            </ItemTemplate> 
        </telerik:MessageControl> 
        <div class="view viewImage">  
            <class="button_area">  
            <!-- BEGIN EXCLUDE FOR COMMUNITY --> 
                <telerik:WorkflowMenu ID="workflowMenu" runat="server" /> 
            <!-- END EXCLUDE FOR COMMUNITY --> 
                <asp:HyperLink ID="editCommand1" runat="server" CssClass="CmsButLeft editdark">   
                    <asp:Literal ID="editLiteral" runat="server" Text="<%$Resources:EditThisPhotoCompEntry %>"></asp:Literal> 
                </asp:HyperLink>      
            </p> 
            <div class="setW clearfix">  
                <div class="setInW clearfix">                         
                    <div class="viewIn">  
                        <h1 class="viewHead">  
                            <asp:Literal ID="itemName" runat="server" /> 
                        </h1> 
                        <telerik:GenericContent ID="contentPreview" runat="server" /> 
                        <asp:PlaceHolder ID="imageHolder" runat="server" Visible="false">      
                            <p> 
                                <asp:HyperLink rel="external" ID="originalLink" runat="server" Text="View original" ToolTip="Opens a new browser window"></asp:HyperLink>&nbsp;<asp:Literal runat="server" ID="dimensionsLabel"></asp:Literal> 
                            </p> 
                            <p><asp:HyperLink rel="external" ID="HyperLink3" runat="server" NavigateUrl='<%# Eval("UrlWithExtension").ToString() %>'><asp:Image runat="server" ID="Image" /></asp:HyperLink></p>  
                        </asp:PlaceHolder> 
                    </div> 
                    <div class="details">  
                        <h3> 
                            <asp:Literal ID="Literal3" Text="<%$Resources:Details %>" runat="server" /> 
                        </h3> 
                        <dl> 
                            <asp:Repeater ID="repeaterItemMetaData" runat="server">  
                            <ItemTemplate> 
                                    <dt> 
                                        <asp:Literal ID="lblKey" runat="server" /> 
                                    </dt> 
                                    <dd> 
                                        <asp:Literal ID="lblValue" runat="server" /> 
                                    </dd> 
                            </ItemTemplate> 
                            </asp:Repeater> 
                        </dl> 
                    </div> 
                </div> 
            </div> 
            <div class="bottomW"><div><!-- --></div></div> 
        </div> 
        <div class="info">  
            <div class="infoBottom">  
            <!-- BEGIN EXCLUDE FOR COMMUNITY --> 
                <asp:PlaceHolder ID="languagePanel" runat="server">  
                    <h3> 
                        <asp:Literal ID="Literal4" Text="<%$Resources:ChangeLanguage %>" runat="server" /> 
                    </h3> 
                    <div class="langCol set">                 
                        <telerik:LanguageBar CssClass="setIn" ID="languageBar" PostBack="True" runat="server">  
                            <LayoutTemplate> 
                                <telerik:LanguageList ID="languageList" runat="server" CssClass="setIn">  
                                    <ItemTemplate> 
                                        <asp:HyperLink ID="listItem" CssClass="emptyLang" runat="server" /> 
                                    </ItemTemplate> 
                                    <CurrentItemTemplate> 
                                        <asp:Label ID="listItem" CssClass="currentLang"  runat="server" /> 
                                    </CurrentItemTemplate> 
                                    <SelectedItemTemplate> 
                                        <asp:HyperLink ID="listItem" CssClass="filledLang" runat="server" /> 
                                    </SelectedItemTemplate> 
                                </telerik:LanguageList> 
                            </LayoutTemplate> 
                        </telerik:LanguageBar>                        
                    </div>    
                    <div class="bottom"><div><!-- --></div></div> 
                </asp:PlaceHolder> 
            <!-- END EXCLUDE FOR COMMUNITY --> 
                <div id="divViewFaq" runat="server">  
                    <h3> 
                        <asp:Literal ID="Literal5" Text="<%$Resources:PhotoCompFAQ %>" runat="server" /> 
                    </h3> 
                    <asp:Literal ID="Literal6" Text="<%$Resources:PhotoCompFAQText %>" runat="server" /> 
                    <class="hideAllFAQs">  
                        <href="javascript:void(0)" onclick="javascript:Personalization.hideFaqSection('<%= divViewFaq.ClientID %>')">Hide FAQs everywhere</a> 
                    </p> 
                </div> 
            </div> 
        </div>                
        <div class="clear"><!-- --></div>  
    </div> 

     

     

     

  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    02 Feb 2010
    Link to this post
    Hello Rick,

    Set the resolvedURL to the ImageUrl property. In your code your are only getting resolvedUrl as string, but then you do not use this variable no where in your code.

    All the best,
    Ivan Dimitrov
    the Telerik team

    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Follow the status of features or bugs in PITS and vote for them to affect their priority.
  5. Grey
    Grey avatar
    2 posts
    Registered:
    04 Jul 2008
    03 Feb 2010
    Link to this post

    Hi Ivan,

    I would like to assign the ImageUrl property.
    However, I can't access any properties in PhotoCompPreview.ascx from PhotoCompPreview.cs

    This is not a typical type of code behind.
    How do I associate string value in PhotoCompPreview.cs to ImageUrl property?

    Thanks,

  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    03 Feb 2010
    Link to this post
    Hello Grey,

    This is a view template. You can add an image to the template and then set the resolved url. You can also access the content item ID from the url. The ID is a QueryString.

    All the best,
    Ivan Dimitrov
    the Telerik team

    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Follow the status of features or bugs in PITS and vote for them to affect their priority.
Register for webinar
6 posts, 0 answered