More in this section

Forums / Developing with Sitefinity / Images and Documents Module

Images and Documents Module

9 posts, 0 answered
  1. Bobby
    Bobby avatar
    56 posts
    Registered:
    11 Feb 2009
    31 May 2010
    Link to this post
    Hi,



        I want to reuse a lot of the functionality provided by the Images and Documents Module. However,
    there are a few things that I want to override in that module.


    I would like to create a document library per document type. So, I believe I would need to add another View
    to the control panel that allows me to add/edit/delete document types.


    I have research areas, which have the hierarchial structure just like categories. However, each
    document can have more than one research area(i.e. category) selected per document. It seems like Sitefinity
    only allows you to have one category per document. I would like to override this behavior to have it
    allow more than one category per document.

    What is the best way to accomplish these goals?

    Thanks for you help,
    Bobby
  2. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    31 May 2010
    Link to this post
    Hello Bobby,

    Thank you for using our services.

    1) You can declare custom types of libraries for the Images and Documents module out of the box. Then you can set the allowed extensions for each type. This will let you limit the file types that can be uploaded there. This is configurable from web.config:
    <libraries defaultGenericProvider="Libraries" streamingProviderName="Files" streamingIsEnabled="True" streamingChunkSize="20971520">
        <genericContentProviders>
            <add providerName="Libraries" publicationDateField="Publication_Date" defaultThumbnailHeight="150" defaultThumbnailWidth="150" />
        </genericContentProviders>
        <libraryInfo>
            <add name="WordDocuments" title="Word Documents Library" defaultExtenstions=".doc, .docx" metaKeys="Author, Description, Extension, Name, Size, Category"></add>
            ...
        </libraryInfo>


    2) If you wish you can use the tags functionality instead of Categories. This will allow you to achieve what you are lookig for with less overriding. The other option is to add a metafield for each additional category you would like to enable on your website.

    All the best,
    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.
  3. Bobby
    Bobby avatar
    56 posts
    Registered:
    11 Feb 2009
    31 May 2010
    Link to this post
    I do not think I can use tags because they do not have a hierarchial structure. My client has a data structure that groups their research areas with categories and sub categories. It's not a one tier architecture like tags. I agree, that would be less work to define a tag for each category but then they lose their grouping and that would be a bad thing. What would be the best way to allow associate multiple categories per document?

  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    31 May 2010
    Link to this post
    Hi Bobby,

    You cannot have more than one category associated with the same content item, but you may have another metakey that acts in the same way as the default Category field. In this case you can reuse the logic for CategoriesField control that is represented as a DropDownList when you create a new item or edit an item that has already been uploaded. When you upload a new item you are automatically redirected to LibraryItemEdit view. The item ID is appended as Param QueryString, so you can easily access it and pass it to LibraryManager.GetContent method.

    1. Map LibraryItemEdit external template
    2. Add second control of type ContenmetaFields inside this template.
    3. Subscribe for Save button - Click event.
    4. Inside Click event get the content item LibraryManager.GetContent
    5. Find the newly added ContenmetaFields control and get its value - you could use RadComboBox control bound to AllCategories. You can get all categories by using GetCategories method of LibraryManager.
    6. Call contentItem.SetMetaData method to persist the value of the second ContenmetaFields control.

    Note that this way allows you to reuse the built in CategoriesView - both ContenmetaFields  will be populated from the same source.

    If the built-in categories does not meet your needs you have to create a custom hierarchical structure and use in the the same way as described above.

    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.
  5. Bobby
    Bobby avatar
    56 posts
    Registered:
    11 Feb 2009
    02 Jun 2010
    Link to this post
    Hi,

         Thanks for your response. You gave me a great idea that I believe my client likes. I have one other question. I creating my own TagsControl which uses a RadComboBox to display the tags. I am getting the ComboBox to display the tags correctly but I am trying to figure out where I can persist the selected tag from the RadComboBox. My first guess is to override the SaveContent function in my class which derives from ContentItemNew<T> and ContentItemEdit<T>. However, I am not sure how to get the content id to of once I call the base.SaveContent(). I need the content id to persist my custom metda data that I get from my radcomboBox. How do I go about doing this?

    Thanks in advance,
    Bobby
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    02 Jun 2010
    Link to this post
    Hi Bobby,

    Inside SaveContent() there is a public property DataItemId which returns the ID of the item that is being saved. You can get the content item by passing the ID to GetContent method of your manager and then call SetMetaData for the content item.


    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.
  7. Bobby
    Bobby avatar
    56 posts
    Registered:
    11 Feb 2009
    02 Jun 2010
    Link to this post
    This is the code that I am using to save persist my custom data.


    protected override void SaveContent()
            {
                DocumentType combo = base.Container.GetControl<DocumentType>("tagsControl", true);
                string tag = combo.Text;
                List<string> tags = new List<string>();
                tags.Add(tag);
                Manager.SaveTags(DataItemId, tags);

                base.SaveContent();
                
            }


    As you can see from the code, I have a custom control called DocumentType. It is located in my edit page with the id of tagsControl. As I said from my previous post, my custom control is displaying my tags correctly. However, when I edit the item and click save, the following error message appears

    A required control was not found in the template for "Medpac.module.document.Resources.ControlTemplates.Backend.MedpacDocEditView.ascx". The control must be assignable form type "Medpac.module.document.WebControls.Admin.DocumentType" and must have ID "tagsControl"




    Can you tell me what I am doing wrong? Also, assuming that I have made a stupid mistake, will that code actually save my tags?
  8. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    02 Jun 2010
    Link to this post
    Hi Bobby,

    In the view that uses MedpacDocEditView.ascx you have a control - which is explicitly set as required and this control should have ID="tagsControl". The control cannot be found in your template and you get an error.

    You should better execute your logic after the base. Here is the API/samples that explains how to work with categories



    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.
  9. Bobby
    Bobby avatar
    56 posts
    Registered:
    11 Feb 2009
    02 Jun 2010
    Link to this post
    As far as I can tell, the control has the id= "tagsControl".

    <fieldset class="set">
                                <ol class="setIn">
                                    <li class="tags">
                                        <medpac:DocumentType ID="tagsControl" runat="server" />
                                    </li>
                                </ol>
                            </fieldset>

    This is in my MedpacDocEditView.ascx template. So, I am not sure why the error message is occuring. Especially, since my custom control has to have that id in order for you Sitefinity software to pass my control the Provider Name and contentId. I am using this information to populate my custom control. So, I am a little confused. Am I thinking about this wrong?
Register for webinar
9 posts, 0 answered