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

Forums / Developing with Sitefinity / Image Gallery with Content Item

Image Gallery with Content Item

33 posts, 0 answered
  1. andersleet
    andersleet avatar
    155 posts
    Registered:
    03 Jun 2009
    10 Jul 2009
    Link to this post
    Hi there. I found these two posts by Ivan Osmak about integrating Image Galleries and News Items.



    I got the code all in place, but under the admin panel I am not getting the dropdown to select an image gallery. To make sure I am looking in the right place, it should be appearing underneath the thumbnail box inside the 'Additional Info' box when you are creating/editing a news item correct?

    I placed all the files where instructed (except for the gallery picker, I moved that to a different folder but updated the references with the new path), placed the classes in the App_Code folder, and added the line into my Web.Config file.

    Do I need to do something so the admin panel will load this particular layout (like regular user controls) over the default one? Or am I missing something else?

    Regards,
    anders
  2. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    13 Jul 2009
    Link to this post
    Hello andersleet,

    Thank you for using our services.

    These blog posts relate to Sitefinity 3.5 where, the control templates are not embedded. This means that in 3.5 you do not need to map the edited control templates in order for your controls to use them (you just have to copy them to the appropriate folder and give the template the right name). However if you are using Sitefinity 3.6 you will have to map the edited controls for the News Module in the admin side. This is one of the reasons you would not see the drop down. One more thing, The names for the control templates in 3.6 are a little bit different. For News  Module the insert and edit controls in admin side use those two templates:
    ~/Sitefinity/Admin/ControlTemplates/News/NewsItemNew.ascx
    ~/Sitefintiy/Admin/ControlTemplates/News/NewsItemEdit.ascx

    Once you have added the code snippet for the drop down to those templates, go to ~/App_Data/Configuration/Telerik.Sitefinity.Configuration.ControlsConfig.xml and add the following viewStrings:
    <?xml version="1.0" encoding="utf-8"?> 
    <controlsConfig> 
      <viewMap> 
       <!--Provides user interface for editing a news item in the News module.--> 
        <viewSettings hostType="Telerik.News.WebControls.Admin.NewsItemEdit" layoutTemplatePath="~/Sitefinity/Admin/ControlTemplates/News/NewsItemEdit.ascx" /> 
        <!--Provides user interface for adding new news items in the News module.--> 
        <viewSettings hostType="Telerik.News.WebControls.Admin.NewsItemNew" layoutTemplatePath="~/Sitefinity/Admin/ControlTemplates/News/NewsItemNew.ascx" /> 
      </viewMap> 
    </controlsConfig> 

    Save the file and restart your web site.

    If this does not solve the problem, please get back to us so that we can see if there any other issues.

    Greetings,
    Rado
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. andersleet
    andersleet avatar
    155 posts
    Registered:
    03 Jun 2009
    13 Jul 2009
    Link to this post
    Thanks for the insight Rado. Unfortunately I have still been unable to get the dropdown to appear. I copied the two templates from the SiteFinity_ExternalTemplates to my ~/Sitefinity/Admin/ControlTemplates/News folder, then added these to both of the files:

    <%@ Register TagPrefix="sfCtg" Namespace="Telerik.Cms.Engine.WebControls.Categories" 
        Assembly="Telerik.Cms.Engine" %> 
    <%@ Register TagPrefix="mycontrols" Src="~/Custom/UserControls/GalleryPicker.ascx" TagName="GalleryPicker" %> 

    And further down under the thumbnail selector declaration:

    <li> 
        <asp:Label ID="Label99" AssociatedControlID="GalleryID" runat="server"
            <asp:Literal ID="Literal24" runat="server" Text="Associated gallery"></asp:Literal> 
            <em id="Em2" runat="server"></em>
        </asp:Label> 
        <mycontrols:GalleryPicker ID="GalleryID" runat="server" GalleryTemplateMode="Lightbox" /> 
    </li> 

    My project did not have that XML file you mentioned, so I had to copy that from the ExternalTemplates download as well (into the ~/App_Code/Configuration/ folder). The paths were already set properly:

    <!--Provides user interface for editing a news item in the News module.--> 
    <viewSettings hostType="Telerik.News.WebControls.Admin.NewsItemEdit" layoutTemplatePath="~/Sitefinity/Admin/ControlTemplates/News/NewsItemEdit.ascx" /> 
    <!--Provides user interface for adding new news items in the News module.--> 
    <viewSettings hostType="Telerik.News.WebControls.Admin.NewsItemNew" layoutTemplatePath="~/Sitefinity/Admin/ControlTemplates/News/NewsItemNew.ascx" /> 

    I also tried putting in some static text at the top of the template:

    <div id="divWorkArea" runat="server" class="workArea"
    TEST 
        <div class="mainForm"
            <class="button_area top"
                <asp:LinkButton ID="saveButton1" runat="server" CssClass="CmsButLeft okdark" Text="<%$Resources:SaveChanges %>" /> 
                <asp:Label ID="Literal8" runat="server" Text="<%$Resources:Or %>" /> 
                <asp:LinkButton ID="cancelButton1" Text="<%$Resources:Cancel %>" runat="server" CssClass="cmscclcmd" 
                    CausesValidation="false" /> 
            </p> 
            <class="mand"
                * 
                <asp:Literal ID="Literal10" runat="server" Text="<%$Resources:MandatoryFields %>"></asp:Literal></p
            <h3> 
                <asp:Label ID="Label1" AssociatedControlID="Title" runat="server"
                    <asp:Literal ID="Literal11" runat="server" Text="<%$Resources:Title %>"></asp:Literal>
                    <em id="TitleLabel" runat="server"></em></asp:Label></h3

    But that text is not showing up either. I tried restarting my webserver and turning it off then turning it back on as well. Is there an extra setting or something else that I need to switch on so SF will read from that configuration XML file? Just an idea :)

    Thanks!
    anders

  4. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    13 Jul 2009
    Link to this post
    Hi andersleet,

    Thank you for getting back to us.

    Did you just copy the xml file from the Configuration folder, or created your own and then copy/pasted the content? I am asking this question because the xml file in the ExternalTemplates.zip file has a slightly different name - Telerik.Sitefinity.Configuration.ControlsConfigAll.xml. Note that renaming this file (remove the All) will map all controls to use the external templates. I would recommend that you map only those that you need. You will also need to restart the website every time you make changes to the controls config xml file in order for changes to take effect.

    If you need to gather more information on the controls config file, and mapping controls to use external templates, please take a look at the following blog posts:
    Introduction to ControlsConfig file
    Mapping a control to use external template

    Kind regards,
    Rado
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  5. andersleet
    andersleet avatar
    155 posts
    Registered:
    03 Jun 2009
    13 Jul 2009
    Link to this post
    I just copied over the XML file, this is the name it had: Telerik.Sitefinity.Configuration.ControlsConfig.xml (thats the correct name right?). I will check out those blog posts and see if I missed anything.

    Regards,
    anders
  6. andersleet
    andersleet avatar
    155 posts
    Registered:
    03 Jun 2009
    13 Jul 2009
    Link to this post
    I should note that this is the ExternalTemplates file I downloaded: Sitefinity_3_6_1936_standard_ExternalTemplates
  7. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    14 Jul 2009
    Link to this post
    Hello andersleet,

    The mapping for the backend works without problems. Please merge the viewSettings from the default ControlsConfig file with yours. Then restart the application and check whether there are any changes. I cannot reproduce any problems related to the templates mapping.

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  8. Chip Gallent
    Chip Gallent avatar
    41 posts
    Registered:
    06 Nov 2009
    18 Aug 2010
    Link to this post
    The lightbox setting in blog post #2 isn't working in 3.7. Is there some other change that is needed to make this work? I have everything else working on the admin side. It's just not showing up on the public side. My guess is that it's something to do with this line:

    <sfLib:ImageGallery id="ImageGallery" runat="server" GalleryTemplateMode="Lightbox"></sfLib:ImageGallery>

    Thanks,
    Chip
  9. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    19 Aug 2010
    Link to this post
    Hello Chip Gallent,

    Please take a look at this forum post

    Regards,
    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. Chip Gallent
    Chip Gallent avatar
    41 posts
    Registered:
    06 Nov 2009
    19 Aug 2010
    Link to this post
    Ivan,

    I saw that, but it's only part of the answer. Where should that code go? In a code-behind? Does it need to be in a new control file?

    Just a little bit more info would be much appreciated.

    Thanks!
  11. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    19 Aug 2010
    Link to this post
    Hi Chip Gallent,

    You can add it inline to the template or inside the code behind - Page_Load

    Regards,
    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
  12. Chip Gallent
    Chip Gallent avatar
    41 posts
    Registered:
    06 Nov 2009
    19 Aug 2010
    Link to this post
    I added it to a code behind and am getting this error:

    Compilation Error

    Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

    Compiler Error Message: CS0118: 'Sitefinity_ControlTemplates_News_ListPageDetails.ImageGallery' is a 'field' but is used like a 'type'

    Source Error:

    Line 14:     protected void Page_Load(object sender, EventArgs e)
    Line 15:     {
    Line 16:         ImageGallery gallery = new ImageGallery();
    Line 17:         gallery.SelectedPresentationMode.ID = "Lightbox";
    Line 18:         gallery.GalleryTemplateMode = ImageGallery.GalleryViewMode.Lightbox;

    Source File: c:\Program Files\telerik\Sitefinity3.7\WebSites\Nashville Health Care Council\Sitefinity\ControlTemplates\News\ListPageDetails.ascx.cs    Line: 16


    Any ideas?

    Thanks!
  13. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    20 Aug 2010
    Link to this post
    Hello Chip Gallent,

    Can you try it like this. It looks like some of the references are messed up:
    Telerik.Libraries.WebControls.ImageGallery gallery = new Telerik.Libraries.WebControls.ImageGallery();


    Regards,
    Radoslav Georgiev
    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. Chip Gallent
    Chip Gallent avatar
    41 posts
    Registered:
    06 Nov 2009
    20 Aug 2010
    Link to this post
    Now another error:

    Compiler Error Message: CS0572: 'GalleryViewMode': cannot reference a type through an expression; try 'Telerik.Libraries.WebControls.ImageGallery.GalleryViewMode' instead

    Source Error:

    Line 16:         Telerik.Libraries.WebControls.ImageGallery gallery = new Telerik.Libraries.WebControls.ImageGallery();
    Line 17:         gallery.SelectedPresentationMode.ID = "Lightbox";
    Line 18:         gallery.GalleryTemplateMode = ImageGallery.GalleryViewMode.Lightbox;
    Line 19:         gallery.BehaviorMode = Telerik.Cms.Engine.WebControls.ContentView.BehaviorModes.Master;
    Line 20:         gallery.ItemListTemplateName = "Telerik.Libraries.Resources.ControlTemplates.Frontend.GalleryLightboxList.ascx";

    Thanks,
    Chip
  15. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    20 Aug 2010
    Link to this post
    Hi Chip Gallent,

    Please try using Telerik.Libraries.WebControls.ImageGallery.GalleryViewMode when setting the mode as described in the error message. It seems that you have a field declared in your control which is called ImageGallery. This is causing all the trouble.

    Kind regards,
    Radoslav Georgiev
    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. Chip Gallent
    Chip Gallent avatar
    41 posts
    Registered:
    06 Nov 2009
    20 Aug 2010
    Link to this post
    I changed a few things and Lightbox still isn't enabling for the control. The image is showing, but when you click on it it just loads the news list page. Here's the code. Can you please take a look and let me know what's missing/wrong. I can't figure it out.

    <%@ Control Language="C#" AutoEventWireup="true" CodeFile="ListPageDetails.ascx.cs" Inherits="Sitefinity_ControlTemplates_News_ListPageDetails" %>
    <%@ Register Assembly="Telerik.Cms.Engine" Namespace="Telerik.Cms.Engine.WebControls" TagPrefix="sfWeb" %>
    <%@ Register Assembly="Telerik.Cms.Web.UI" Namespace="Telerik.Web.UI.SpamProtection" TagPrefix="sfWeb" %>
    <%@ Register Assembly="Telerik.Libraries" Namespace="Telerik.Libraries.WebControls" TagPrefix="sfLib" %>
    <%@ Register Assembly="App_Code" Namespace="RandomSFCode.MetaMaster2008" TagPrefix="cc1" %>
    <cc1:MetaMaster ID="MetaMaster1" runat="server"
        <Mappings>
            <cc1:MetaMapping MetaKey="GalleryID" TargetControlId="ImageGallery" TargetProperty="FilterExpression" TargetPropertyStringFormat="ParentID IN ({0})" />
        </Mappings>
    </cc1:MetaMaster>
    <telerik:CssFileLink ID="CssFileLink1" EmbeddedFileName="" FileName="newsCommonLayout.css" Media="screen" runat="server" />
    <telerik:JsFileLink id="jsLink" runat="server" ScriptType="jQuery" />
         
    <div class="sf_singleNews">
        <div class="printNews"><a href="javascript:window.print();"><img src="/Images/print-icon.png" align="absmiddle" /></a> <a href="javascript:window.print();">Print</a></div>
        <div class="sf_back"><asp:HyperLink ID="backToList1" Text="<%$Resources:AllNews %>" runat="server"></asp:HyperLink></div>
        <h2 class="sf_NewsTitle">
            <asp:Literal ID="Title" runat="server"></asp:Literal>
        </h2>
        <p class="sf_newsDate">
            <asp:Literal ID="Publication_Date" runat="server" Text="{0}" />
        </p>
        <p>
            <asp:Literal ID="Summary" runat="server"></asp:Literal>
        </p>
        <p>
            <asp:Literal ID="content" runat="server"></asp:Literal>
        </p>
        <div>
            <sfLib:ImageGallery id="ImageGallery" runat="server" ></sfLib:ImageGallery>
        </div>
        <p class="sf_newsAuthor">
            <asp:Literal ID="Author" runat="server"></asp:Literal>
        </p>
        <p>
            <asp:Literal ID="Source" runat="server"></asp:Literal>
        </p>
        <p class="sf_postCategory">
            <asp:HyperLink ID="Category" runat="server" />
        </p>
         
        <asp:Repeater ID="Tags" runat="server">
            <HeaderTemplate><p class="sf_postTags"></HeaderTemplate>
            <ItemTemplate>
                <asp:HyperLink ID="tagLink" runat="server" />
            </ItemTemplate>
            <FooterTemplate></p></FooterTemplate>
        </asp:Repeater>
         
         
        <asp:Repeater ID="Bookmarks" runat="server">
            <HeaderTemplate><p class="sf_postBookmark"></HeaderTemplate>
            <ItemTemplate>
                <asp:HyperLink ID="BookmarkLink" runat="server">
                    <asp:Image ID="BookmarkImage" runat="server" />
                </asp:HyperLink>
            </ItemTemplate>
            <FooterTemplate></p></FooterTemplate>
        </asp:Repeater>
         
        <div id="comments" class="sf_contentComments">
            <sfWeb:CommentsList id="commentsList" runat="server" cssclass="sf_commentsList" ValidationGroup="commentInfo"></sfWeb:CommentsList>
        </div>
    </div>

    Here's the code-behind:
    using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
     
    public partial class Sitefinity_ControlTemplates_News_ListPageDetails : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Telerik.Libraries.WebControls.ImageGallery gallery = new Telerik.Libraries.WebControls.ImageGallery();
            gallery.SelectedPresentationMode.ID = "Lightbox";
            gallery.GalleryTemplateMode = Telerik.Libraries.WebControls.ImageGallery.GalleryViewMode.Lightbox;
            gallery.BehaviorMode = Telerik.Cms.Engine.WebControls.ContentView.BehaviorModes.Master;
            gallery.ItemListTemplateName = "Telerik.Libraries.Resources.ControlTemplates.Frontend.GalleryLightboxList.ascx";
            Controls.Add(gallery);
        }
    }


    Thanks,
    Chip
  17. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    20 Aug 2010
    Link to this post
    Hello Chip Gallent,

    Try the bellow code in your Page_Load event handler:
    protected void Page_Load(object sender, EventArgs e)
    {
        ImageGallery.SelectedPresentationMode.ID = "Lightbox";
        ImageGallery.GalleryTemplateMode = Telerik.Libraries.WebControls.ImageGallery.GalleryViewMode.Lightbox;
        ImageGallery.BehaviorMode = Telerik.Cms.Engine.WebControls.ContentView.BehaviorModes.Master;
        ImageGallery.ItemListTemplateName = "Telerik.Libraries.Resources.ControlTemplates.Frontend.GalleryLightboxList.ascx";
    }

    Sincerely yours,
    Radoslav Georgiev
    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
  18. Chip Gallent
    Chip Gallent avatar
    41 posts
    Registered:
    06 Nov 2009
    20 Aug 2010
    Link to this post
    That did the trick. Thanks a ton...as usual.

    - Chip
  19. Chip Gallent
    Chip Gallent avatar
    41 posts
    Registered:
    06 Nov 2009
    24 Aug 2010
    Link to this post
    One more thing popped up today. I was setting up the web.config to append the news item title to the breadcrumb and then I got this error:

    Object reference not set to an instance of an object.
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
     
    Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
     
    Source Error:
     
    Line 101:            {
    Line 102:                IContent cnt = cntManager.GetContent(contentView.SelectedItemId);
    Line 103:                string metaValue = cnt.GetMetaData(this.MetaKey).ToString();
    Line 104:                if(!String.IsNullOrEmpty(targetPropertyStringFormat))
    Line 105:                {
     
     
    Source File: c:\Program Files\telerik\Sitefinity3.7\WebSites\Nashville Health Care Council\App_Code\MetaMapping.cs    Line: 103

    It only happens with news items that do not have an associated image gallery. Any ideas?

    Thanks,
    Chip
  20. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    24 Aug 2010
    Link to this post
    Hi Chip Gallent,

    Have you tried to debug the code to see which of the objects is null? This is a general ASP.NET  error - there is a null object that you are trying to use.

    The MetaMappings.cs should be altered as below, otherwise a object reference error will be thrown on GetMetaData() if the key has not be set or it is empty value.

    IContent cnt = cntManager.GetContent(contentView.SelectedItemId);
    string metaValue = string.Empty;
    object objVal = cnt.GetMetaData(this.MetaKey);
    if (objVal != null)
      metaValue = objVal.ToString();


    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
  21. Chip Gallent
    Chip Gallent avatar
    41 posts
    Registered:
    06 Nov 2009
    24 Aug 2010
    Link to this post
    Well that worked, but something new popped up. When I load the news in detail mode with the ListPageDetail template I'm getting this error now:

    Left operand '11dbf188-9143-4a9f-a1c3-140dae28025c' is not supported. Supported left operands are :
     
        * Name
        * Width
        * Height
        * Size
        * Extension
        * AlternateText
        * Author
        * Description
        * Category
        * PermaLink
        * ID
        * Tag.ID
        * Tag.Name
        * ParentID
     
    Join type 'ParentID' is not supported. Left operand 'IN' is not supported. Supported left operands are :
     
        * Name
        * Width
        * Height
        * Size
        * Extension
        * AlternateText
        * Author
        * Description
        * Category
        * PermaLink
        * ID
        * Tag.ID
        * Tag.Name
        * ParentID

    Could this be from something else in that MetaMappings.cs file? Or, somewhere else?

    Also - when you view a news item that has no gallery associated with it - I see all image galleries listed now.

    Thanks,
    Chip
  22. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    24 Aug 2010
    Link to this post
    Hi Chip Gallent,

    The error says that you are trying to use a guid as a operand which is not supported. The error has shown you the valid operands that you may use. Check the FilterExpression property of the control you are using.

    Regards,
    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
  23. Chip Gallent
    Chip Gallent avatar
    41 posts
    Registered:
    06 Nov 2009
    24 Aug 2010
    Link to this post
    Here's what is in that filter:

    Publication_Date <= "#now" AND Expiration_Date > "#now" AND Category IN ("Press Releases")

    That operand is the id of the image gallery that it's trying to load. I'm using the code that is cited in post #1 of this thread. Any ideas as to what else it should be? Everything was working fine until I modified the web.config - now it's all broken.
  24. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    25 Aug 2010
    Link to this post
    Hi Chip Gallent,

    I am not able to reproduce this issue using the MetaMapping code. The error comes from the FilterExpression property of the control, although the value you pasted looks fine.

    Kind regards,
    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
  25. Chip Gallent
    Chip Gallent avatar
    41 posts
    Registered:
    06 Nov 2009
    25 Aug 2010
    Link to this post
    Hmm - I checked the ListPageDetails.ascx and saw this at the top of the code:

    <%@ Control Language="C#" AutoEventWireup="true" CodeFile="ListPageDetails.ascx.cs" Inherits="Sitefinity_ControlTemplates_News_ListPageDetails" %>
    <%@ Register Assembly="Telerik.Cms.Engine" Namespace="Telerik.Cms.Engine.WebControls" TagPrefix="sfWeb" %>
    <%@ Register Assembly="Telerik.Cms.Web.UI" Namespace="Telerik.Web.UI.SpamProtection" TagPrefix="sfWeb" %>
    <%@ Register Assembly="Telerik.Libraries" Namespace="Telerik.Libraries.WebControls" TagPrefix="sfLib" %>
    <%@ Register Assembly="App_Code" Namespace="RandomSFCode.MetaMaster2008" TagPrefix="cc1" %>
    <cc1:MetaMaster ID="MetaMaster1" runat="server"
        <Mappings>
            <cc1:MetaMapping MetaKey="GalleryID" TargetControlId="ImageGallery" TargetProperty="FilterExpression" TargetPropertyStringFormat="ParentID IN ({0})" />
        </Mappings>
    </cc1:MetaMaster>

    That TargetProperty might be the issue. Also, here is the code in the section of the page:
    <div>
    <sfLib:ImageGallery id="ImageGallery" runat="server" ></sfLib:ImageGallery>
    </div>

    - Chip
  26. Chip Gallent
    Chip Gallent avatar
    41 posts
    Registered:
    06 Nov 2009
    30 Aug 2010
    Link to this post
    I've been looking into this and think there might be something in the MetaMappings.cs file that could be triggering this.

    Here's that section that you asked me to edit a few posts ago:

    public virtual void MapValue(ContentView contentView)
            {
                ContentManager cntManager = new ContentManager(contentView.ProviderName);
                if (cntManager.MetaKeys.ContainsKey(this.MetaKey))
                {
                    IContent cnt = cntManager.GetContent(contentView.SelectedItemId);
                    string metaValue = string.Empty;
                    object objVal = cnt.GetMetaData(this.MetaKey);
                    if (objVal != null)
                    {
                        metaValue = objVal.ToString();
                    }
     
                    // find the target control
                    if (!String.IsNullOrEmpty(this.TargetControlID) && contentView != null)
                    {
                        Control ctrl = FindControlRecursive(contentView, this.TargetControlID);
                        if (ctrl != null)
                        {
                            Type ctrlType = ctrl.GetType();
                            PropertyInfo pInfo = ctrlType.GetProperty(this.TargetProperty);
                            if (pInfo != null)
                                pInfo.SetValue(ctrl, metaValue, null);
                        }
                    }
                }
            }
    If I comment out the second part starting with:
    if (!String.IsNullOrEmpty(this.TargetControlID) && contentView != null)
    then I do not get any errors, but all of the images from the image galleries show up. When that code is left in, the error from above still shows up. Any ideas?

    - Chip
  27. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    01 Sep 2010
    Link to this post
    Hi Chip Gallent,

    1. Instead o fusing FilterExpression property to add the parent Ids use ParentIDs as a target property.

    <cc1:MetaMaster ID="MetaMaster1" runat="server">   
        <Mappings>  
            <cc1:MetaMapping MetaKey="GalleryID" TargetControlId="ImageGallery1" TargetProperty="ParentIDs"  />  
        </Mappings>  
    </cc1:MetaMaster>


    2. Modify MetaMappings class as shown below

    public virtual void MapValue(ContentView contentView)
           {
               ContentManager cntManager = new ContentManager(contentView.ProviderName);
               if (cntManager.MetaKeys.ContainsKey(this.MetaKey))
               {
     
                   IContent cnt = cntManager.GetContent(contentView.SelectedItemId);
                   string metaValue = string.Empty; object objVal = cnt.GetMetaData(this.MetaKey);
                   if (objVal != null)
                       metaValue = objVal.ToString();
     
                   if (!String.IsNullOrEmpty(metaValue))
                       ReturnGuid(metaValue);
                    
                   if (!String.IsNullOrEmpty(this.TargetControlID) && contentView != null)
                   {
                       Control ctrl = FindControlRecursive(contentView, this.TargetControlID);
                       if (ctrl != null)
                       {
                           Type ctrlType = ctrl.GetType();
                           PropertyInfo pInfo = ctrlType.GetProperty(this.TargetProperty);
                           if (pInfo != null)
                               pInfo.SetValue(ctrl, this.ReturnGuid(metaValue), null);
                       }
                   }
               }
           }
     
           public virtual Guid[] ReturnGuid(string value)
           {
               var guid = new Guid[1];
               guid[0] = new Guid(value);
               var ids = guid;
               return ids;
           }

    OnLoad of the template ListPageDetails you should add this control

    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);
        ImageGallery gallery = new ImageGallery();
        gallery.ID = "ImageGallery1";
        gallery.SelectedPresentationMode.ID = "Lightbox";
        gallery.GalleryTemplateMode = ImageGallery.GalleryViewMode.Lightbox;
        gallery.BehaviorMode = Telerik.Cms.Engine.WebControls.ContentView.BehaviorModes.Master;
        gallery.ItemListTemplateName = "Telerik.Libraries.Resources.ControlTemplates.Frontend.GalleryLightboxList.ascx";
        Controls.Add(gallery);
     
    }

    I attached a sample video.

    Kind regards,
    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
  28. Chip Gallent
    Chip Gallent avatar
    41 posts
    Registered:
    06 Nov 2009
    01 Sep 2010
    Link to this post
    Ivan - I made those changes now I'm getting this error.

    Compilation Error
    Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
     
    Compiler Error Message: CS0246: The type or namespace name 'ImageGallery' could not be found (are you missing a using directive or an assembly reference?)
     
    Source Error:
     
    Line 15:    {
    Line 16:        base.OnLoad(e);
    Line 17:        ImageGallery gallery = new ImageGallery();
    Line 18:        gallery.ID = "ImageGallery1";
    Line 19:        gallery.SelectedPresentationMode.ID = "Lightbox";
     
     
    Source File: c:\Program Files\telerik\Sitefinity3.7\WebSites\Nashville Health Care Council\Sitefinity\ControlTemplates\News\ListPageDetails.ascx.cs    Line: 17

    There has to be something out of sync here. Can you ZIP up your files and attach them? I'll need /App_Code/MetaMappings.cs, /App_Code/MetaMaster.cs, /Sitefinity/ControlTemplates/News/ListPageDetails.ascx & /Sitefinity/ControlTemplates/News/ListPageDetails.ascx.cs - something just had to be out of sync here.

    Any other ideas?

    Thanks so much for helping me work through this! Your help is really appreciated.

    - Chip
  29. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    01 Sep 2010
    Link to this post
    Hi Chip Gallent,

    You have to add reference to Telerik.Libraries.WebControls.

    Regards,
    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
  30. Chip Gallent
    Chip Gallent avatar
    41 posts
    Registered:
    06 Nov 2009
    01 Sep 2010
    Link to this post
    Ok, now I'm getting this error from something in the MetaMappings.cs file:

    Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
     
    Exception Details: System.FormatException: Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).
     
    Source Error:
     
    Line 126:       {
    Line 127:          var guid = new Guid[1];
    Line 128:          guid[0] = new Guid(value);
    Line 129:          var ids = guid;
    Line 130:          return ids;
     
     
    Source File: c:\Program Files\telerik\Sitefinity3.7\WebSites\Nashville Health Care Council\App_Code\MetaMapping.cs    Line: 128
     
    Stack Trace:
     
    [FormatException: Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).]
       System.Guid..ctor(String g) +2486
       RandomSFCode.MetaMaster2008.MetaMapping.ReturnGuid(String value) in c:\Program Files\telerik\Sitefinity3.7\WebSites\Nashville Health Care Council\App_Code\MetaMapping.cs:128
       RandomSFCode.MetaMaster2008.MetaMapping.MapValue(ContentView contentView) in c:\Program Files\telerik\Sitefinity3.7\WebSites\Nashville Health Care Council\App_Code\MetaMapping.cs:119
       RandomSFCode.MetaMaster2008.MetaMaster.OnPreRender(EventArgs e) in c:\Program Files\telerik\Sitefinity3.7\WebSites\Nashville Health Care Council\App_Code\MetaMaster.cs:88
       System.Web.UI.Control.PreRenderRecursiveInternal() +80
       System.Web.UI.Control.PreRenderRecursiveInternal() +171
       System.Web.UI.Control.PreRenderRecursiveInternal() +171
       System.Web.UI.Control.PreRenderRecursiveInternal() +171
       System.Web.UI.Control.PreRenderRecursiveInternal() +171
       System.Web.UI.Control.PreRenderRecursiveInternal() +171
       System.Web.UI.Control.PreRenderRecursiveInternal() +171
       System.Web.UI.Control.PreRenderRecursiveInternal() +171
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +842

    Here are the contents of that file - seems like something is out of whack somewhere:
    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Web.UI.WebControls;
    using System.Web.UI;
    using System.Reflection;
    using Telerik.Cms.Engine.WebControls;
    using Telerik.Cms.Engine;
     
    namespace RandomSFCode.MetaMaster2008
    {
        /// <summary>
        /// This class represents single mapping of meta-field value to an arbitrary property
        /// of specified control inside of a ContentView template
        /// </summary>
        public class MetaMapping : CompositeControl, IStateManager
        {
            #region Properties
     
            /// <summary>
            /// Gets or sets the key of meta-field for which the value should be mapped
            /// </summary>
            public string MetaKey
            {
                get
                {
                    return this.metaKey;
                }
                set
                {
                    this.metaKey = value;
                }
            }
     
            /// <summary>
            /// Gets or sets the id of the control whose property will be set to the value
            /// of meta-field
            /// </summary>
            public string TargetControlID
            {
                get
                {
                    return this.targetControlID;
                }
                set
                {
                    this.targetControlID = value;
                }
            }
     
            /// <summary>
            /// Gets or sets the name of the property which value will be set to the value of
            /// meta-field
            /// </summary>
            public string TargetProperty
            {
                get
                {
                    return this.targetProperty;
                }
                set
                {
                    this.targetProperty = value;
                }
            }
     
            public string TargetPropertyStringFormat
            {
                get
                {
                    return targetPropertyStringFormat;
                }
                set
                {
                    targetPropertyStringFormat = value;
                }
            }
     
            #endregion
     
            #region Overriden Methods
     
            protected override void CreateChildControls()
            {
                // do not create child controls
            }
     
            #endregion
     
            #region Methods
     
            /// <summary>
            /// This method find the target control and sets the target property to the value
            /// of specified meta key
            /// </summary>
            /// <param name="contentView"></param>
            public virtual void MapValue(ContentView contentView)
            {
               ContentManager cntManager = new ContentManager(contentView.ProviderName);
               if (cntManager.MetaKeys.ContainsKey(this.MetaKey))
               {
             
                   IContent cnt = cntManager.GetContent(contentView.SelectedItemId);
                   string metaValue = string.Empty; object objVal = cnt.GetMetaData(this.MetaKey);
                   if (objVal != null)
                       metaValue = objVal.ToString();
             
                   if (!String.IsNullOrEmpty(metaValue))
                       ReturnGuid(metaValue);
                     
                   if (!String.IsNullOrEmpty(this.TargetControlID) && contentView != null)
                   {
                       Control ctrl = FindControlRecursive(contentView, this.TargetControlID);
                       if (ctrl != null)
                       {
                           Type ctrlType = ctrl.GetType();
                           PropertyInfo pInfo = ctrlType.GetProperty(this.TargetProperty);
                           if (pInfo != null)
                               pInfo.SetValue(ctrl, this.ReturnGuid(metaValue), null);
                       }
                   }
               }
            }
             
            public virtual Guid[] ReturnGuid(string value)
            {
               var guid = new Guid[1];
               guid[0] = new Guid(value);
               var ids = guid;
               return ids;
            }
     
            private Control FindControlRecursive(Control root, string id)
            {
                if (root.ID != null && root.ID == id)
                    return root;
     
                foreach (Control c in root.Controls)
                {
                    Control rc = FindControlRecursive(c, id);
                    if (rc != null)
                        return rc;
                }
                return null;
            }
     
            internal void SetDirty()
            {
                ViewState.SetDirty(true);
            }
     
            #endregion
     
            #region Private fields
     
            string metaKey;
            string targetControlID;
            string targetProperty;
            string targetPropertyStringFormat;
     
            #endregion
     
            #region IStateManager Members
     
            public new bool IsTrackingViewState
            {
                get
                {
                    return base.IsTrackingViewState;
                }
            }
     
            public new void LoadViewState(object state)
            {
                base.LoadViewState(state);
            }
     
            public new object SaveViewState()
            {
                return base.SaveViewState();
            }
     
            public new void TrackViewState()
            {
                base.TrackViewState();
            }
     
            #endregion
        }
    }

    - Chip
Register for webinar
33 posts, 0 answered
1 2