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

Forums / Developing with Sitefinity / Thumbnails for the Products Module

Thumbnails for the Products Module

29 posts, 1 answered
  1. James
    James avatar
    25 posts
    Registered:
    15 May 2009
    21 Jun 2010
    Link to this post
    Hi,

    I am evaluating Sitefinity 3.6+7 at the moment and have had a good look at the latest up to date custom Products Module. I am trying to achieve two things that I can't seem to find the right resource for displaying.

    1. I need to show a thumbnail for each item which is displayed (just like the news module) so I need to plug the admin view in to add a thumbnail as well as allow it in the user control.

    2. I need to strip out the 'content' i.e. with 0 words and 0 pictures in the item list (just like the news module).

    Is this easy to do? I have tried doing it with the news module but couldn't find the correct resource for changing the link text for the permanent link (which appears 'full story') and the return to all items link (which displays 'All News'). So I then tried the products module, and wasn't able to add the thumbnail functionality. Any help would be appreciated. Many thanks

    JJ
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    21 Jun 2010
    Link to this post
    Hello James,

    1. Please take a look at our UserManual - page 219 - Adding custom fields. You should create a new metakey and use ButtonSelector control that will allow you to select an image

    <li class="selector">
                           <asp:Label ID="Label2" AssociatedControlID="Thumbnail" runat="server"><asp:Literal ID="Literal14" runat="server" Text="<%$Resources:Thumbnail %>"></asp:Literal> <em id="ThumbnailLabel" runat="server"></em></asp:Label>
                           <asp:TextBox ID="Thumbnail" Text="" runat="server" MaxLength="250"></asp:TextBox>
                           <sfLib:ButtonSelector WindowNavigateUrl="~/Sitefinity/UserControls/Dialogs/DocumentEditorDialog.aspx" ItemTemplatePath="~/Sitefinity/Admin/ControlTemplates/News/Dialogs/ButtonSelector.ascx" AssociatedControls="Thumbnail" runat="server" cssclass="pickerWrapper" ButtonText="<%$Resources:Select%>" />
                           <p class="example">
                               <asp:Literal ID="Literal15" runat="server" Text="<%$Resources:ThumbnailNote %>"></asp:Literal>
                           </p>
                       </li>

    2. You need to create a custom public control of your module. So you need to create a custom control that inherits from ContentView and implement Control Designer or public properties that will be used to strip the content.

    You could use Summary Settings control or implement your logic that changes the content of the IContent item.  In your custom control you could override SetItemMetadata method as the posts above shows to get access to the IContent object, Item container and all controls inside the repeater that displays the item data.

    Greetings,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. James
    James avatar
    25 posts
    Registered:
    15 May 2009
    21 Jun 2010
    Link to this post
    Hi Ivan,

    Thanks for getting back to me, I added:

    <add key="Products.Thumbnail" valueType="ShortText" visible="True" searchable="False" sortable="False" defaultValue="" />

    to my web.config and

    <data name="Thumbnail" xml:space="preserve">
        <value>Thumbnail</value>
    </data>

    To my ~\Sitefinity\Admin\ControlTemplates\Products\App_LocalResources\ControlPanelEdit.ascx.resx and
               ~\Sitefinity\Admin\ControlTemplates\Products\App_LocalResources\ControlPanelInsert.ascx.resx files

    the build succeeds but when I navigate to 'Create a new item' in the Products Module I get:

    [ArgumentException: The key "Thumbnail" is not defined for resource "Telerik.Samples.Products.Resources.Messages"]
       Telerik.Cms.Web.UI.Templates.Attribute.GetValue(SubstitutionItem subst, Object component, Control bindingContainer) +526
       Telerik.Cms.Web.UI.Templates.Attribute.GetValue(PropertyDescriptor descriptor, Object component, Control bindingContainer) +270
       Telerik.Cms.Web.UI.Templates.Attribute.SetAttribute(Object component, Control bindingContainer, Boolean bound) +632
       Telerik.Cms.Web.UI.Templates.Attribute.SetAttribute(Object component, Control bindingContainer) +65
       Telerik.Cms.Web.UI.Templates.ObjectBuilder.CreateObject(Control bindingContainer) +392
       Telerik.Cms.Web.UI.Templates.ControlBuilder.CreateControl(Control bindingContainer) +74
       Telerik.Cms.Web.UI.Templates.RootBuilder.CreateChildControls(Control parent, Control bindingContainer) +467
       Telerik.Cms.Web.UI.Templates.ObjectBuilder.CreateObject(Control bindingContainer) +764
       Telerik.Cms.Web.UI.Templates.ControlBuilder.CreateControl(Control bindingContainer) +74
       Telerik.Cms.Web.UI.Templates.SimpleTmplate.InstantiateIn(Control container) +391
       Telerik.Cms.Engine.WebControls.ContentMetaFields.CreateChildControls() +783
       System.Web.UI.Control.EnsureChildControls() +146
       System.Web.UI.WebControls.CompositeControl.get_Controls() +20
       Telerik.Framework.Web.ControlTraverser.GetBreadthFirst(Boolean isRecursionCall) +319
       Telerik.Framework.Web.ControlTraverser.GetBreadthFirst(Boolean isRecursionCall) +868
       Telerik.Framework.Web.ControlTraverser.GetBreadthFirst(Boolean isRecursionCall) +868
       Telerik.Framework.Web.ControlTraverser.GetBreadthFirst(Boolean isRecursionCall) +868
       Telerik.Framework.Web.ControlTraverser.GetBreadthFirst(Boolean isRecursionCall) +868
       Telerik.Framework.Web.ControlTraverser.Next() +146
       Telerik.Framework.Web.ControlTraverser.MoveNext() +46
       Telerik.Cms.Web.UI.GenericContainer.FindTypedControl(String id, Type searchType, TraverseMethod method) +441
       Telerik.Cms.Web.UI.GenericContainer.GetControl(String id, Boolean required, TraverseMethod method) +284
       Telerik.Cms.Engine.WebControls.Admin.ContentItemEdit`1.get_TagsControl() +129
       Telerik.Cms.Engine.WebControls.Admin.ContentItemEdit`1.SetContentEditForm() +4113
       Telerik.Cms.Engine.WebControls.Admin.ContentItemEdit`1.InitializeControls(Control viewContainer) +72
       Telerik.Cms.Engine.WebControls.Admin.ContentItemNew`1.InitializeControls(Control viewContainer) +56
       Telerik.Cms.Web.UI.ViewModeControl`1.CreateChildControls() +333
       System.Web.UI.Control.EnsureChildControls() +146
       System.Web.UI.Control.PreRenderRecursiveInternal() +61
       System.Web.UI.Control.PreRenderRecursiveInternal() +224
       System.Web.UI.Control.PreRenderRecursiveInternal() +224
       System.Web.UI.Control.PreRenderRecursiveInternal() +224
       System.Web.UI.Control.PreRenderRecursiveInternal() +224
       System.Web.UI.Control.PreRenderRecursiveInternal() +224
       System.Web.UI.Control.PreRenderRecursiveInternal() +224
       System.Web.UI.Control.PreRenderRecursiveInternal() +224
       System.Web.UI.Control.PreRenderRecursiveInternal() +224
       System.Web.UI.Control.PreRenderRecursiveInternal() +224
       System.Web.UI.Control.PreRenderRecursiveInternal() +224
       System.Web.UI.Control.PreRenderRecursiveInternal() +224
       System.Web.UI.Control.PreRenderRecursiveInternal() +224
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3394

    Any ideas what this could be?

    Many thanks

    JJ
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    21 Jun 2010
    Link to this post
    Hello James,

    You have a reference to <%$Resources:Thumbnail %>
    The error says that you do not have this resource key in the correct template or the template and its resx are not build as an embedded resource. Since the code complains only for the custom metakey, but not for all other fields I believe that the key is not properly added to the resx file.

    Best wishes,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. James
    James avatar
    25 posts
    Registered:
    15 May 2009
    21 Jun 2010
    Link to this post
    Hi Ivan,

    I fixed that error by registering the Thumbnail string properly in the code behind, thanks :)

    I'm getting another error now however, I think it's being thrown by Telerik.Samples.Products\Resources\ControlTemplates\Backend\ProductNewView.ascx

    I can't seem to register the libraries assembly..
    <%@ Register TagPrefix="sfLib" Namespace="Telerik.Libraries.WebControls" Assembly="Telerik.Libraries" %>

    in my controls, the intellisense doesn't show up. I added the Telerik.Libraries reference to the project and again it compiles but when I navigate to the 'Create a new item' button I get the following error.

    [ArgumentException: Could not resolve type for tag "sfLib:ButtonSelector". Make sure the proper namespace is registered.]
       Telerik.Cms.Web.UI.Templates.TemplateParser.ResolveType(String tag) +1141
       Telerik.Cms.Web.UI.Templates.TemplateParser.CreateObjectBuilder(HtmlChunk chunk) +222
       Telerik.Cms.Web.UI.Templates.TemplateParser.ParseOpenTag(HtmlChunk chunk) +522
       Telerik.Cms.Web.UI.Templates.TemplateParser.ParseChunk(HtmlChunk chunk) +162
       Telerik.Cms.Web.UI.Templates.TemplateParser.Parse() +257
       Telerik.Cms.Web.UI.Templates.ObjectBuilder.ParseHtml(TemplateParser parser) +157
       Telerik.Cms.Web.UI.Templates.ObjectBuilder.ParseHtml(String html) +147
       Telerik.Cms.Web.UI.Templates.ObjectBuilder..ctor(ObjectBuilder parent, String html) +102
       Telerik.Cms.Web.UI.Templates.ObjectBuilder..ctor(ObjectBuilder parent, String html, ResourceManager resourceManager) +66
       Telerik.Cms.Web.UI.Templates.ControlBuilder..ctor(ObjectBuilder parent, String html, ResourceManager resourceManager) +71
       Telerik.Cms.Web.UI.Templates.TemplateBuilder..ctor(String html, PropertyBuilder parent) +64
       Telerik.Cms.Web.UI.Templates.PropertyBuilder.ParseProperty(String html) +120
       Telerik.Cms.Web.UI.Templates.PropertiesParser.ParseCloseTag(HtmlChunk chunk) +572
       Telerik.Cms.Web.UI.Templates.TemplateParser.ParseChunk(HtmlChunk chunk) +974
       Telerik.Cms.Web.UI.Templates.TemplateParser.Parse() +257
       Telerik.Cms.Web.UI.Templates.ObjectBuilder.ParseHtml(TemplateParser parser) +157
       Telerik.Cms.Web.UI.Templates.PropertiesBuilder.ParseHtml(String html) +102
       Telerik.Cms.Web.UI.Templates.ObjectBuilder..ctor(ObjectBuilder parent, String html) +102
       Telerik.Cms.Web.UI.Templates.ObjectBuilder..ctor(ObjectBuilder parent, String html, ResourceManager resourceManager) +66
       Telerik.Cms.Web.UI.Templates.PropertiesBuilder..ctor(String html, ObjectBuilder parent) +64
       Telerik.Cms.Web.UI.Templates.TemplateParser.FinalizeCurrentBuilder() +582
       Telerik.Cms.Web.UI.Templates.TemplateParser.ParseCloseTag(HtmlChunk chunk) +389
       Telerik.Cms.Web.UI.Templates.TemplateParser.ParseChunk(HtmlChunk chunk) +974
       Telerik.Cms.Web.UI.Templates.TemplateParser.Parse() +257
       Telerik.Cms.Web.UI.Templates.ObjectBuilder.ParseHtml(TemplateParser parser) +157
       Telerik.Cms.Web.UI.Templates.ObjectBuilder.ParseHtml(String html) +147
       Telerik.Cms.Web.UI.Templates.ObjectBuilder..ctor(ObjectBuilder parent, String html) +102
       Telerik.Cms.Web.UI.Templates.ObjectBuilder..ctor(ObjectBuilder parent, String html, ResourceManager resourceManager) +66
       Telerik.Cms.Web.UI.Templates.ControlBuilder..ctor(ObjectBuilder parent, String html, ResourceManager resourceManager) +71
       Telerik.Cms.Web.UI.Templates.RootBuilder..ctor(ResourceManager resourceManager, String html, ObjectBuilder parent) +71
       Telerik.Cms.Web.UI.Templates.TemplateParser.FinalizeCurrentBuilder() +723
       Telerik.Cms.Web.UI.Templates.TemplateParser.ParseCloseTag(HtmlChunk chunk) +389
       Telerik.Cms.Web.UI.Templates.TemplateParser.ParseChunk(HtmlChunk chunk) +974
       Telerik.Cms.Web.UI.Templates.TemplateParser.Parse() +257
       Telerik.Cms.Web.UI.Templates.ObjectBuilder.ParseHtml(TemplateParser parser) +157
       Telerik.Cms.Web.UI.Templates.ObjectBuilder.ParseHtml(String html) +147
       Telerik.Cms.Web.UI.Templates.ObjectBuilder..ctor(ObjectBuilder parent, String html) +102
       Telerik.Cms.Web.UI.Templates.ObjectBuilder..ctor(ObjectBuilder parent, String html, ResourceManager resourceManager) +66
       Telerik.Cms.Web.UI.Templates.ControlBuilder..ctor(ObjectBuilder parent, String html, ResourceManager resourceManager) +71
       Telerik.Cms.Web.UI.Templates.RootBuilder..ctor(ResourceManager resourceManager, String html, ObjectBuilder parent) +71
       Telerik.Cms.Web.UI.Templates.RootBuilder..ctor(ResourceManager resourceManager, String html) +64
       Telerik.Framework.Web.StringTemplate..ctor(String declaration, ResourceManager resourceManager, String templateName) +108
       Telerik.Framework.Web.ControlUtils.GetTemplate(String virtualPath, String resourceFileName, Type assemblyInfo, Type localizationAssemblyInfo) +1569
       Telerik.Framework.Web.ControlUtils.GetTemplate(String virtualPath, String resourceFileName, Type assemblyInfo, Type localizationAssemblyInfo, Type templateMapType, String additionalTemplateKey) +969
       Telerik.Cms.Web.UI.ViewModeControl`1.CreateLayoutTemplate(Type assemblyInfo, Type localizationAssemblyInfo) +401
       Telerik.Cms.Web.UI.ViewModeControl`1.get_LayoutTemplate() +122
       Telerik.Cms.Web.UI.ViewModeControl`1.get_Container() +168
       Telerik.Cms.Web.UI.ViewModeControl`1.CreateChildControls() +141
       System.Web.UI.Control.EnsureChildControls() +146
       System.Web.UI.Control.PreRenderRecursiveInternal() +61
       System.Web.UI.Control.PreRenderRecursiveInternal() +224
       System.Web.UI.Control.PreRenderRecursiveInternal() +224
       System.Web.UI.Control.PreRenderRecursiveInternal() +224
       System.Web.UI.Control.PreRenderRecursiveInternal() +224
       System.Web.UI.Control.PreRenderRecursiveInternal() +224
       System.Web.UI.Control.PreRenderRecursiveInternal() +224
       System.Web.UI.Control.PreRenderRecursiveInternal() +224
       System.Web.UI.Control.PreRenderRecursiveInternal() +224
       System.Web.UI.Control.PreRenderRecursiveInternal() +224
       System.Web.UI.Control.PreRenderRecursiveInternal() +224
       System.Web.UI.Control.PreRenderRecursiveInternal() +224
       System.Web.UI.Control.PreRenderRecursiveInternal() +224
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3394

    Thanks Ivan, for replying so quickly, I think you guys have the fastest response time I've seen so far! I hope I can fix this next step.. Cheers,

    James.
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    21 Jun 2010
    Link to this post
    Hello James,

    The tag prefix registration looks correct. Make sure that the module has reference to Telerik.Libraries.dll in from your bin and the template is build as embedded resource.

    Greetings,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  7. James
    James avatar
    25 posts
    Registered:
    15 May 2009
    21 Jun 2010
    Link to this post
    Hi Ivan,

    Looks like this part is working now. I recompiled. I will let you know if anything else goes wrong! Thank you so much for your help

    JJ
  8. James
    James avatar
    25 posts
    Registered:
    15 May 2009
    21 Jun 2010
    Link to this post
    Hi Ivan,

    I believe I am almost there, I created a ContentViewItemList and ContentViewSingleItem. There are no errors when I go through the process of adding a product, however the path to the image is not not being populated and the Select link isn't styled. When I add the path manually it still doesn't show a thumbnail. Also the picker doesn't recognise that I have a library.

    One thing I did notice is it's opening a dialogue-

    "Now, the document is selected.
    A link to it will be inserted in your content."


    So I don't think it's firing the right function, if compared to the news module it brings up a window entitled 'Thumbnail'.

    Which part am I missing? So close!

    Thanks

    JJ
  9. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    22 Jun 2010
    Link to this post
    Hello James,

    Try using the following dialogs for the ButtonSelector control

    <sfLib:ButtonSelector WindowNavigateUrl="~/Sitefinity/UserControls/Dialogs/ImageEditorDialog.aspx" AssociatedControls="Thumbnail" ItemTemplatePath="~/Sitefinity/Admin/ControlTemplates/News/Dialogs/ButtonSelector.ascx" runat="server" cssclass="pickerWrapper" ButtonText="Select" />

    Note that the value of the Thumbnail will be returned as dynamic url - [Provider]Guid that should be resolved on the public control -Resolving the url of dynamic links


    Greetings,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  10. James
    James avatar
    25 posts
    Registered:
    15 May 2009
    22 Jun 2010
    Link to this post
    Hi Ivan,

    It's changed to the Image dialogue now, thanks. However the chosen image and path aren't being passed back to the input box. I am also now getting an error:

    Request information:
        Request path: /MySite/Sitefinity/Admin/Modules.aspx
        User host address: ::1
        User: admin
        Is authenticated: True
        Authentication Type: Forms
        Thread account name: IIS APPPOOL\DefaultAppPool
      
    Thread information:
        Thread ID: 14
        Thread account name: IIS APPPOOL\DefaultAppPool
        Is impersonating: False
        Stack trace:    at Telerik.Cms.Web.UI.Templates.PropertiesParser.ParseOpenTag(HtmlChunk chunk)
       at Telerik.Cms.Web.UI.Templates.TemplateParser.ParseChunk(HtmlChunk chunk)
       at Telerik.Cms.Web.UI.Templates.TemplateParser.Parse()
       at Telerik.Cms.Web.UI.Templates.ObjectBuilder.ParseHtml(TemplateParser parser)
       at Telerik.Cms.Web.UI.Templates.PropertiesBuilder.ParseHtml(String html)
       at Telerik.Cms.Web.UI.Templates.ObjectBuilder..ctor(ObjectBuilder parent, String html)
       at Telerik.Cms.Web.UI.Templates.ObjectBuilder..ctor(ObjectBuilder parent, String html, ResourceManager resourceManager)
       at Telerik.Cms.Web.UI.Templates.PropertiesBuilder..ctor(String html, ObjectBuilder parent)
       at Telerik.Cms.Web.UI.Templates.TemplateParser.FinalizeCurrentBuilder()
       at Telerik.Cms.Web.UI.Templates.TemplateParser.ParseCloseTag(HtmlChunk chunk)
       at Telerik.Cms.Web.UI.Templates.TemplateParser.ParseChunk(HtmlChunk chunk)
       at Telerik.Cms.Web.UI.Templates.TemplateParser.Parse()
       at Telerik.Cms.Web.UI.Templates.ObjectBuilder.ParseHtml(TemplateParser parser)
       at Telerik.Cms.Web.UI.Templates.ObjectBuilder.ParseHtml(String html)
       at Telerik.Cms.Web.UI.Templates.ObjectBuilder..ctor(ObjectBuilder parent, String html)
       at Telerik.Cms.Web.UI.Templates.ObjectBuilder..ctor(ObjectBuilder parent, String html, ResourceManager resourceManager)
       at Telerik.Cms.Web.UI.Templates.ControlBuilder..ctor(ObjectBuilder parent, String html, ResourceManager resourceManager)
       at Telerik.Cms.Web.UI.Templates.RootBuilder..ctor(ResourceManager resourceManager, String html, ObjectBuilder parent)
       at Telerik.Cms.Web.UI.Templates.TemplateParser.FinalizeCurrentBuilder()
       at Telerik.Cms.Web.UI.Templates.TemplateParser.ParseCloseTag(HtmlChunk chunk)
       at Telerik.Cms.Web.UI.Templates.TemplateParser.ParseChunk(HtmlChunk chunk)
       at Telerik.Cms.Web.UI.Templates.TemplateParser.Parse()
       at Telerik.Cms.Web.UI.Templates.ObjectBuilder.ParseHtml(TemplateParser parser)
       at Telerik.Cms.Web.UI.Templates.ObjectBuilder.ParseHtml(String html)
       at Telerik.Cms.Web.UI.Templates.ObjectBuilder..ctor(ObjectBuilder parent, String html)
       at Telerik.Cms.Web.UI.Templates.ObjectBuilder..ctor(ObjectBuilder parent, String html, ResourceManager resourceManager)
       at Telerik.Cms.Web.UI.Templates.ControlBuilder..ctor(ObjectBuilder parent, String html, ResourceManager resourceManager)
       at Telerik.Cms.Web.UI.Templates.RootBuilder..ctor(ResourceManager resourceManager, String html, ObjectBuilder parent)
       at Telerik.Cms.Web.UI.Templates.RootBuilder..ctor(ResourceManager resourceManager, String html)
       at Telerik.Framework.Web.ControlUtils.StringTemplate..ctor(String declaration, ResourceManager resourceManager, String templateName)
       at Telerik.Framework.Web.ControlUtils.GetTemplate(String virtualPath, String resourceFileName, Type assemblyInfo, Type localizationAssemblyInfo)
       at Telerik.Framework.Web.ControlUtils.GetTemplate(String virtualPath, String resourceFileName, Type assemblyInfo, Type localizationAssemblyInfo, Type templateMapType, String additionalTemplateKey)
       at Telerik.Cms.Web.UI.ViewModeControl`1.CreateLayoutTemplate(Type assemblyInfo, Type localizationAssemblyInfo)
       at Telerik.Cms.Web.UI.ViewModeControl`1.get_LayoutTemplate()
       at Telerik.Cms.Web.UI.ViewModeControl`1.get_Container()
       at Telerik.Cms.Web.UI.ViewModeControl`1.CreateChildControls()
       at System.Web.UI.Control.EnsureChildControls()
       at System.Web.UI.Control.PreRenderRecursiveInternal()
       at System.Web.UI.Control.PreRenderRecursiveInternal()
       at System.Web.UI.Control.PreRenderRecursiveInternal()
       at System.Web.UI.Control.PreRenderRecursiveInternal()
       at System.Web.UI.Control.PreRenderRecursiveInternal()
       at System.Web.UI.Control.PreRenderRecursiveInternal()
       at System.Web.UI.Control.PreRenderRecursiveInternal()
       at System.Web.UI.Control.PreRenderRecursiveInternal()
       at System.Web.UI.Control.PreRenderRecursiveInternal()
       at System.Web.UI.Control.PreRenderRecursiveInternal()
       at System.Web.UI.Control.PreRenderRecursiveInternal()
       at System.Web.UI.Control.PreRenderRecursiveInternal()
       at System.Web.UI.Control.PreRenderRecursiveInternal()
       at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

    I can't find what has caused this, even rolled back my project..

    JJ
  11. James
    James avatar
    25 posts
    Registered:
    15 May 2009
    22 Jun 2010
    Link to this post
    I looked at my log and the error originates from

    Request information:
        Request URL: /MySite/Sitefinity/Admin/Modules.aspx?module=Products&route=ProductsControlPanel.ProductsView.ProductNewView&ParentId=00000000-0000-0000-0000-000000000000
        Is Authenticated: True
        Authentication Type: Forms
        User: admin
        User Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-GB; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3
        User Address: ::1

    Something to do with url re-writing, I think I am overriding the embedded templates somewhere so will try to fix this using the forums.

    JJ
  12. James
    James avatar
    25 posts
    Registered:
    15 May 2009
    22 Jun 2010
    Link to this post
    Hi Ivan,

    I managed to get back to where I was this morning by recreating the project, to show what I am actually seeing I have attached some images. The problem is the event isn't firing when I insert item from the products module picker. You can see the javascript isn't posting anything back to the form when I click insert item.

    In newsnewitem.jpg I am hovering over the select button, the same in productsnewitem.jpg Similarly I am hovering over the Insert button for the next two images also (Insert & I'm done). Where can I find the function to insert the path back into the field on the form? Thanks for your help thus far,

    JJ
  13. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    23 Jun 2010
    Link to this post
    Hi James,

    I prepared a sample project for you which is attached to this post. Please run it locally.

    Best wishes,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  14. James
    James avatar
    25 posts
    Registered:
    15 May 2009
    23 Jun 2010
    Link to this post
    Hi Ivan,

    It's close, did it run on your dev machine? It's passing the string back to the input box now, thanks, but still no thumbnail on resulting view. I have created a page with the ProductsPublicView and NewsView where you can see the news view works and products doesn't yet. Is there anything else I need to do?
  15. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    23 Jun 2010
    Link to this post
    Hi James,

    Have you resolved the dynamic url?

    Greetings,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  16. James
    James avatar
    25 posts
    Registered:
    15 May 2009
    23 Jun 2010
    Link to this post
    Hi Ivan,

    I will do now :) Thanks,

    JJ
  17. James
    James avatar
    25 posts
    Registered:
    15 May 2009
    23 Jun 2010
    Link to this post
    Hi Ivan,

    I am overriding the ItemListTemplatePath with an external template within the control..

    In my Products Custom Control if I use the placeholder from the News Control Template
    <asp:PlaceHolder ID="ThumbnailHolder" runat="server">
                    <p class="sf_newsThumbnail"><asp:Image ID="Thumbnail" runat="server" /></p>
                </asp:PlaceHolder>

    I don't get anything and if I use
    <p class="sf_newsThumbnail">
                    <asp:Literal ID="Thumbnail" runat="server"></asp:Literal>
                </p>

    It returns:

    Product name...

    [Libraries]0b913808-8110-4590-bb29-db21e654242f

    Type your content here...

    Product Details


    I know I am missing something due to lack of understanding of the CMS. I followed Georgi's post for my ProductsPublicView.cs

    using System;
    using System.Web;
    using Telerik.Cms.Engine.WebControls;
    using Telerik.Cms.Engine;
     
    namespace Telerik.Samples.Products.WebControls
    {
        /// <summary>
        /// Public control for displaying products
        /// </summary>
        public class ProductsPublicView : ContentView
        {
            /// <summary>
            /// Gets the type from the assembly containing the embedded localization resource.
            /// Override if embedded templates are using ASP.NET localization.
            /// </summary>
            /// <value></value>
            public override Type LocalizationAssemblyInfo
            {
                get
                {
                    return typeof(ContentView);
                }
                set
                {
                    base.LocalizationAssemblyInfo = value;
                }
            }
     
            /// <summary>
            /// Gets the type from the assembly containing the embedded resources.
            /// Cannot be null reference.
            /// </summary>
            /// <value></value>
            public override Type AssemblyInfo
            {
                get
                {
                    return typeof(ContentView);
                }
                set
                {
                    base.AssemblyInfo = value;
                }
            }
     
            /// <summary>
            /// If this property is empty the control will try to detect if a provider is specified in the request or it will use the default provider.
            /// </summary>
            /// <value></value>
            public override string ProviderName
            {
                get
                {
                    object obj = ViewState["ProviderName"];
                    if(obj != null)
                        return (string) obj;
                    return ProductsManager.DefaultContentProvider;
                }
                set
                {
                    ViewState["ProviderName"] = value;
                }
            }
            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);
            }
        }
    }

    Do I need to change the code in this file? It doesn't seem to be returning the url. Thanks for the time you are taking on this, I appreciate it.

    JJ
  18. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    23 Jun 2010
    Link to this post
    Hi James,

    Override SeItemMetadata method and find the custom control you have added from the itemConatiner. Then you can get the thumbnail value using GetMetaData of the IContent object which is also parameter of this method and resolve the link by passing the Guid to GetItemUrl

    Best wishes,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  19. Nauman
    Nauman avatar
    23 posts
    Registered:
    02 Jun 2010
    23 Jun 2010
    Link to this post
    Sorry guys for interrupting, but a question for Ivan is there a way to add multiple thumbnails to single product ?

    TIA

    Nauman
  20. James
    James avatar
    25 posts
    Registered:
    15 May 2009
    23 Jun 2010
    Link to this post
    Hi Ivan,

    I have done that, I now have this code in my ProductsPublicView.cs

    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);
            }
            protected override void SetItemMetadata(System.Web.UI.Control itemContainer, Telerik.Cms.Engine.IContent contentItem)
            {
                base.SetItemMetadata(itemContainer, contentItem);
     
                Image thumb = itemContainer.FindControl("Thumbnail") as Image;
                if (thumb != null)
                {
                    String thumbReference = contentItem.GetMetaData("Thumbnail").ToString();
     
                    if (String.IsNullOrEmpty(thumbReference))
                    {
                        thumb.Visible = false;
                    }
                    else
                    {
                        thumb.ImageUrl = thumbReference;
                        thumb.Visible = true;
                    }
                }
            }

    I'm still getting the same output as before
    with

    <asp:PlaceHolder ID="ThumbnailHolder" runat="server">
                    <p class="sf_newsThumbnail">
                        <asp:Image ID="Thumbnail" runat="server" /></p>
    </asp:PlaceHolder>

    and

    <p class="sf_newsThumbnail">
                    <asp:Literal ID="Thumbnail" runat="server"></asp:Literal>
    </p>

    in my ContentViewItemList.ascx

    I have plowed through the forums along with your suggestions. Nothing seems to work. I shall however post my results once it is working :) Any other suggestions? Thanks again,

    JJ

  21. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    23 Jun 2010
    Link to this post
    Hello James,

    You have never used GetItemUrl to resolve the link so you are keep assigning a not resolved url to the Thumbnail.

    Best wishes,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  22. James
    James avatar
    25 posts
    Registered:
    15 May 2009
    23 Jun 2010
    Link to this post
    Sorry Ivan,

    I should have explained I have only been developing for 8 months as I came from a html & css background , so far I've hit the ground running, could you explain where I use GetItemUrl ? Then that should be it I guess! Thanks for your help

    JJ
  23. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    23 Jun 2010
    Link to this post
    Hi James,

    Here is a quick sample

    protected override void SetItemMetadata(System.Web.UI.Control itemContainer, Telerik.Cms.Engine.IContent contentItem)
            {
                base.SetItemMetadata(itemContainer, contentItem);
      
                Image thumb = itemContainer.FindControl("Thumbnail") as Image;
                if (thumb != null)
                {
                    String thumbReference = contentItem.GetMetaData("Thumbnail").ToString();
      
                    if (String.IsNullOrEmpty(thumbReference))
                    {
                        thumb.Visible = false;
                    }
                    else
                    {
                        string resolvedUrl = GetItemUrl(thumbReference, true);
                        thumb.ImageUrl = resolvedUrl;
                        thumb.Visible = true;
                    }
                }
            }
     
     
    private string GetItemUrl(string val, bool resolveAsAbsoluteUrl)
        {
            if (val.StartsWith("~/"))
                return this.ResolveUrl(val);
     
            int idx = val.IndexOf("]");
     
            if (idx < 0)
            {
                return val;
            }
     
            string provider = val.Substring(1, idx - 1);
            string strId = val.Substring(idx + 1);
            Guid id = new Guid(strId);
     
            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
            {
                string url = CmsHelper.GetPageUrl(id, this.Context);
                if (!string.IsNullOrEmpty(url))
                {
                    return url;
                }
            }
            return String.Concat("Item not found: [", provider, "]", id);
        }



    Best wishes,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  24. James
    James avatar
    25 posts
    Registered:
    15 May 2009
    23 Jun 2010
    Link to this post
    Ivan,

    The quick example gets me half way there, this is turning into spaghetti. To summarise I can see I need two functions in my ProductsPublicView:

    1.    SetItemMetadata

    The final code I have gleaned from numerous different examples across Sitefinity versions is as follows:

    protected override void SetItemMetadata(System.Web.UI.Control itemContainer, Telerik.Cms.Engine.IContent contentItem)
            {
                base.SetItemMetadata(itemContainer, contentItem);
                Image thumb = itemContainer.FindControl("Thumbnail") as Image;
                if (thumb != null)
                {
                    String thumbReference = contentItem.GetMetaData("Thumbnail").ToString();
      
                    if (String.IsNullOrEmpty(thumbReference))
                    {
                        thumb.Visible = false;
                    }
                    else
                    {
                        string resolvedUrl = GetItemUrl(thumbReference, true);
                        thumb.ImageUrl = thumbReference;
                        thumb.Visible = true;
                    }
                }
            }


    And I now have no less than 3 alternatives for GetItemUrl none of which work.

    1
    private string GetItemUrl(string val, bool resolveAsAbsoluteUrl)
            {
                if (val.StartsWith("~/"))
                    return this.ResolveUrl(val);
     
                int idx = val.IndexOf("]");
     
                if (idx < 0)
                {
                    return val;
                }
     
                string provider = val.Substring(1, idx - 1);
                string strId = val.Substring(idx + 1);
                Guid id = new Guid(strId);
     
                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
                {
                    string url = CmsHelper.GetPageUrl(id, this.Context);
                    if (!string.IsNullOrEmpty(url))
                    {
                        return url;
                    }
                }
                return String.Concat("Item not found: [", provider, "]", id);
            }
    2
    private 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);
            }
    3
    private string GetUrl(string value)
            {
                // if our value starts with ~/  
                // we return url 
                if (value.StartsWith("~/"))
                    return this.ResolveUrl(value);
     
                if (value.StartsWith("["))
                {
                    int idx = value.IndexOf("]");
                    //getting the provider [Libraries] 
                    string provider = value.Substring(1, idx - 1);
                    string strId = value.Substring(idx + 1);
                    Guid id = new Guid(strId);
     
                    if (ContentManager.Providers.ContainsKey(provider))
                    {
                        IContent cnt = ContentManager.Providers[provider].GetContent(id);
                        if (cnt != null)
                            return VirtualPathUtility.ToAbsolute(cnt.UrlWithExtension, this.Context.Request.ApplicationPath);
                    }
                }
                return value.ToString();
            }

    Somewhere in the midst of these 3 I need just the one function that works to complete this marathon. If anyone reading this has come across this before and has the function lying around please share it. Many thanks

    JJ
  25. James
    James avatar
    25 posts
    Registered:
    15 May 2009
    24 Jun 2010
    Link to this post
    This is as close as I can get it

    protected override void SetItemMetadata(System.Web.UI.Control itemContainer, Telerik.Cms.Engine.IContent contentItem)
            {
                base.SetItemMetadata(itemContainer, contentItem);
                Image thumb = itemContainer.FindControl("Thumbnail") as Image;
                if (thumb != null)
                {
                    //thumb.imageUrl = contentItem.GetMetaData("Thumbnail").ToString();
     
                    String thumbReference = contentItem.GetMetaData("Thumbnail").ToString();
     
                    if (String.IsNullOrEmpty(thumbReference))
                    {
                        thumb.Visible = false;
                    }
                    else
                    {
                        string resolvedUrl = GetItemUrl(thumbReference);
                        thumb.ImageUrl = resolvedUrl;
                        thumb.Visible = true;
                    }
                }
            }
     
            private string GetItemUrl(string thumbReference)
            {
                // if our value starts with ~/
                // return url
                if (thumbReference.StartsWith("~/"))
                return this.ResolveUrl(thumbReference);
     
                if (thumbReference.StartsWith("["))
                {
                    int idx = thumbReference.IndexOf("]");
     
                    //if (idx < 0)
                    //{
                    //    return thumbReference;
                    //}
                    // getting the provider (Libraries)
                    string provider = thumbReference.Substring(1, idx - 1);
                    string strId = thumbReference.Substring(idx + 1);
                    Guid id = new Guid(strId);
     
                    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
                    {
                        string url = CmsHelper.GetPageUrl(id, this.Context);
                        if (!string.IsNullOrEmpty(url))
                        {
                            return url;
                        }
                    }
                    return String.Concat("Item not found: [", provider, "]", id);
                }
                return thumbReference.ToString();
            }


    Please see the attached image for the result. It just won't pass the result back to the thumbnail url..

    JJ
  26. James
    James avatar
    25 posts
    Registered:
    15 May 2009
    24 Jun 2010
    Link to this post
    Hi Ivan,

    Please could you review my last post and see what is missing? I am desperate to get this finished for tomorrow. I have to demo Sitefinity to my boss who gave me a specific requirement for which a web design agency said they could build with N2Cms. I am up against the clock a little with this and would love to be able to use Sitefinity for our new website. My demo site is completely finished other than this 1 requirement, image previews on products/services. I appreciate your team must be busy and any further help you can give. Thanks,

    JJ
  27. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    24 Jun 2010
    Link to this post
    Hi James,

    I attached a sample project with products module and public control for it which resolves the url of an dynamic metakey and set it as ImageUrl of an Image control declared into the control template. The control has been create under App_Code folder.


    All the best,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
    Answered
  28. James
    James avatar
    25 posts
    Registered:
    15 May 2009
    24 Jun 2010
    Link to this post
    Hi Ivan,

    The sample works! Thank you so much, I am tying it into my demo at the moment, with a little tweaking for version 3.6. Many thanks

    JJ
  29. James
    James avatar
    25 posts
    Registered:
    15 May 2009
    25 Jun 2010
    Link to this post
    Hi Ivan,

    I think I figured out what the problem was... I am using version 3.6 the control templates and functions you have mentioned previously are different for different versions of sitefinity. I used Beyond Compare to check out the code and due to updated assemblies the functions change. Unless you have the same project which I marked as solution in the 3.6 version I am going to have to leave it. Thank you for all of your help this week. I would be stuck at the starting block without it.

    Regards

    JJ
Register for webinar
29 posts, 1 answered