More in this section

Forums / Developing with Sitefinity / Extending Image Library metatags and showing them in admin form (version 3.6)

Extending Image Library metatags and showing them in admin form (version 3.6)

6 posts, 1 answered
  1. Marc Potters
    Marc Potters avatar
    4 posts
    Registered:
    27 Jul 2009
    27 Jul 2009
    Link to this post
    I'm a first time user of sitefinity so bear with me. A customer has some specific wishes which I need to implement.
    NOTE: The version of Sitefinity we use is 3.6.(1936.2).

    Basicly I want the following thing. I want to make an Image Library, where I have at least the following 'properties \ metatags'.
    1) URL (this is not the url of the image)
    2) Text
    3) Alternative Text (already present)
    4) Location of the Image (But I guess that's already present by uploading the image ... ;) ... )
    I need these 'properties \ metatags' te be editable bij the admin. It's explicitly forbidden to misuse existing 'properties \ metatags' (So no URL data in the Author metatag, but I can live with using the Description 'metatag' for the Text).

    When I make an Image Library I have the following 'properties \ metatags' at my disposal for the items in the details (admin)form: Autor, Alternative text, Width and Height.

    I want to extend this (admin)form with Text and URL, (and that the admin can edit these values and get stored in the database of course!) What is the easiest way to accomplisch this in version 3.6.(1936.2).

    In web.config I notice that there exist more 'properties \ metatags' are already know for libraries then shown in an Image List. So I can live with using the Description 'metatag for the Text.

    Kind Regards,

    Marc Potters

  2. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    27 Jul 2009
    Link to this post
    Hello Marc Potters,

    Thank you for using our services.

    Achieving the desired functionality is fairly easy. Since the Images & Documents module is a Generic Content based module you have the ability to add your custom metafields to content items. You can take a look at the following blog post to see how to do it:
    Adding Custom Fields to Existing Sitefinity Modules.

    The article uses the Events module as an example, but the logic for the Images & Documents is similar. in the web.config you just have to declare the metafileds like this:
    <add key="Libraries.Text" valueType="ShortText" visible="True" searchable="True" sortable="True" defaultValue="" localizable="true"/> 

    Then you will need to download the ExternalTemplates.zip from your Client.Net account (see attached image), and some of the control templates. First you will need to edit the templates for managing content items to the libraries in the back end. The templates for those files are:
    ~/Sitefinity/Admin/ControlTemplates/Libraries/LibraryItemEdit.ascx,
    ~/Sitefinity/Admin/ControlTemplates/Libraries/LibraryItemPreview.ascx,
    ~/Sitefinity/Admin/ControlTemplates/Libraries/LibraryItemBatchEdit.ascx
    You have to edit those templates as described in the article.

    After that you will have to edit the template for displaying image in the public end, to show your custom metafields. The associated control templates for that are:
    ~/Sitefinity/ControlTemplates/Libraries/GaleryListView.ascx
    ~/Sitefinity/ControlTemplates/Libraries/GaleryListViewItem.ascx
    ~/Sitefinity/ControlTemplates/Libraries/ItemView.ascx

    Finally you have to map the edited control templates, so that your controls know that they have to use them. For more information on how to do this, please take a look here: Mapping a control to use external template.

    I hope that you will find the provided information useful. If you have more questions, do not hesitate to contact us.

    All the best,
    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. Marc Potters
    Marc Potters avatar
    4 posts
    Registered:
    27 Jul 2009
    28 Jul 2009
    Link to this post
    Thank you for the quick reply,
    I followed the steps you described in the reply, and I think I'm close to getting it to work. The problem is that I don't see the new 'metatags' in the new template.

    I did the following:

    1) Added 2 items in the webconfig <add key="Libraries.URL" ... and <add key="Libraries.Text"
    <add key="Libraries.URL" valueType="ShortText" visible="True" searchable="True" sortable="True" defaultValue="" /> 
    <add key="Libraries.Text" valueType="ShortText" visible="True" searchable="True" sortable="True" defaultValue="" /> 
     
    2) Added 3 templates in the libraries dir, and altered the LibraryItemEditX to show also the new metatags URL and Text (the text for the label is not yet put in the resource file):
    <li> 
    <asp:Label ID="Label7" AssociatedControlID="Author" runat="server" Text="TEST"></asp:Label> 
    <asp:TextBox runat="server" ID="Author"></asp:TextBox> 
    </li> 
    <li> 
    <asp:Label ID="Label5" runat="server" AssociatedControlID="Description" Text="<%$Resources:ItemEdit_DocumentDescription %>"></asp:Label> 
    <asp:TextBox runat="server" ID="Description" TextMode="MultiLine"></asp:TextBox> 
    </li> 
    <li> 
    <asp:Label ID="Label11" runat="server" AssociatedControlID="URL" Text="URL"></asp:Label> 
    <asp:TextBox runat="server" ID="URL" TextMode="MultiLine"></asp:TextBox> 
    </li> 
    <li> 
    <asp:Label ID="Label13" runat="server" AssociatedControlID="Text" Text="TEXT"></asp:Label> 
    <asp:TextBox runat="server" ID="Text" TextMode="MultiLine"></asp:TextBox> 
    </li> 

    3) Added 3 items in the Telerik.Sitefinity.Configuration.ControlsConfig.xml (in the app_Data\Configuration dir), which point to the new templates. In this case also the adapted LibraryItemEditX.ascx.
    <viewSettings hostType="Telerik.Libraries.WebControls.Admin.LibraryItemEdit"
    layoutTemplatePath="~/Sitefinity/Admin/ControlTemplates/Libraries/LibraryItemEditX.ascx" /> 
    4) Put the resource files for the new templates in the designated resource folder.
    5) Added Text and URL in the <libraryInfo> part of the webconfig
    <add name="Image" title="Image Library" defaultExtenstions=".png, .jpg, .jpeg, .gif" metaKeys="Author, AlternateText, Extension, Name, Height, Width, Size, Category, URL, Text"></add> 
     

    6) Cleaned the solution, build it and run it.

    Problem: I don't see the new 'metatags' in the LibraryItemEdit(X).
    I think it tries to read the new template, because when I point it in the ControlsConfig.xml to a non existing template an exception is thrown. Web.config items seems to be read, because i can see them in the "Search items by"-dropdown on the images overview page. I do see the new metatags in the preview page.
    Note: What I see in the adressbar of the browser on the LibraryItemEdit(X) page:
    "...Modules.aspx?module=Libraries&route=LibrariesControlPanel.LibraryItemsView.LibraryItemEdit&ParentId=81ab...", I expected to see in the Bold part LibraryItemEditX, but that may be a misconception on my part.

    Is there a step I missed ?
    Can it be a version problem (again, we use version 3.6.1936.2) ?

    Kind regards,

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

    Thank you for getting back to me.

    You are going in the right direction. If you take a closer look at the LibraryItemEdit.ascx file you will see that you have two <sfGCn:ContentMetaFields> tags. One is with ID="itemMetaFields" and the other one is with ID="imageMetaFields". I have edited my ~/Sitefinity/Admin/ControlTemplates/LibraryItemEdit.ascx template exactly as you have, but note that I have put the texboxes for the metafields in the <sfGCn:ContentMetaFields ID="imageMetaFields" runat="server"> tag like this. And then mapped the edited template. It worked as expected, see attached image for reference. Can you please verify that you have put the metafields in the correct tag.

    Best wishes,
    Rado
    the Telerik team

    Instantly find answers to your questions on the newTelerik Support Portal.
    Check out the tipsfor optimizing your support resource searches.
    Answered
  5. Marc Potters
    Marc Potters avatar
    4 posts
    Registered:
    27 Jul 2009
    28 Jul 2009
    Link to this post
    Yep, that solved it.

    Never occured to me there were 2 <sfGCN:ContentMetaFields ...
    Thanks for the excellent information and quick replies.
  6. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    28 Jul 2009
    Link to this post
    Hello Marc Potters,

    Always glad to help the community. If you have more questions, please feel free to post in our forums or raise a support ticket.

    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.
Register for webinar
6 posts, 1 answered