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

Forums / Developing with Sitefinity / DownloadList with custom field

DownloadList with custom field

6 posts, 0 answered
  1. Kumar
    Kumar avatar
    3 posts
    Registered:
    17 Oct 2013
    11 Nov 2013
    Link to this post
    Hi, 
    I am new to sitefinity.

    i want to create a widget to upload files and display files like downloadlist widget
    and also i want to allow user to enter the title field to that library

    suppose

    i have a library category 1

    in that i have file1, file2

    and in category 1 i have another library and contains file3, file4

    so i want to display the files like below and i selected category1 library in library option

    Title
    ------------------------------
    Category1
    -file1
    -file2
    -Category2
        -file3
        -file4

    please help
    thanks in advance....
  2. David C
    David C avatar
    33 posts
    Registered:
    02 Dec 2015
    12 Nov 2013
    Link to this post
    Hi Kumar,

    My apologies, I don't think I'm exactly following what you need to do. Can you give me a step by step user story on how your custom widget will work?

    Also, have you considered using the Digital Asset Manager for this task?

     - Drag & Drop Digital Asset Libraries

    Regards,
    David C
    Telerik
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Kumar
    Kumar avatar
    3 posts
    Registered:
    17 Oct 2013
    12 Nov 2013 in reply to David C
    Link to this post
    Hi David,

    Thanks for reply. Actually i want to modify the Downloadlist but i have to allow the user to enter the title of this document list

    means when displaying the uploaded file, i want to show it in tree view with bullet list.
    the library name as title and its file under this as child  and if that library have another library then it i will also display in that and this sub library's files as its child as shown in the image which is attached

    please find the attached image

        




  4. David C
    David C avatar
    33 posts
    Registered:
    02 Dec 2015
    13 Nov 2013
    Link to this post
    Hi Kumar,

    Please take a look at the following documentation: Documents and files. This will go into detail about how to use the Sitefinity API to create libraries and documents. 

    I would recommend using Sitefinity Thunder to build a custom widget and then adding your code to create libraries and upload documents. Please note that Sitefinity doesn't have an upload component, so you will need code the upload dialog using C# or VB.Net.

    Hopefully this helps. Please let us know if you have any additional questions. 

    Regards,
    David C
    Telerik
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. Kumar
    Kumar avatar
    3 posts
    Registered:
    17 Oct 2013
    15 Nov 2013 in reply to David C
    Link to this post
    Hi David,

    I created a widget like downloadlist using documents api

    DownloadListsNewModel.cs
    -------------------------------------------------------------

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Linq;
    using System.Web;
    using Telerik.Sitefinity.GenericContent.Model;
    using Telerik.Sitefinity.Libraries.Model;
    using Telerik.Sitefinity.Modules.Libraries;

    namespace SitefinityWebApp.Mvc.Models
    {
        public class DownloadListsNewModel
        {
            public DownloadListsNewModel(IQueryable<Document> documents,List<DocumentLibrary>  librariesList)
            {
                this.Items = documents;
                this.LibrariesList = librariesList;
            }

            public IQueryable<Document> Items
            { 
                get;
                private set;
            }
            public List<DocumentLibrary> LibrariesList
            {
                get;
                private set;
            }

            public string Title { get; set; }

        }



    }



    DownloadListsNewController.cs
    ---------------------------------------------------------------------------


    using SitefinityWebApp.Mvc.Models;
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Linq;
    using System.Web;
    using System.Web.Mvc;
    using Telerik.Sitefinity;
    using Telerik.Sitefinity.GenericContent.Model;
    using Telerik.Sitefinity.Libraries.Model;
    using Telerik.Sitefinity.Modules.Libraries;
    using Telerik.Sitefinity.Mvc;


    namespace SitefinityWebApp.Mvc.Controllers
    {
        [ControllerToolboxItem(Name = "MVC DownloadList", Title = "MVC DownLoadList", SectionName = "MvcNewWidgets")]
        public class DownloadListsNewController:Controller
        {
            public ActionResult Index()
            {

                LibrariesManager librariesManager = LibrariesManager.GetManager();
                var documents= librariesManager.GetDocuments().Where(d => d.Status == ContentLifecycleStatus.Live);

                var documentsLibraries = App.WorkWith().DocumentLibraries().Get().Distinct().ToList();

                var documentsModel = new DownloadListsNewModel(documents,documentsLibraries )
                {
                    Title=this.Title
                }; 

                return View("DownloadListsNew", documentsModel);
            }

            [Category("String Properties")]
            public string Title{get;set;}


        }
    }


    DownloadListsNew.cshtml
    ---------------------------------------------------------------------


    @model SitefinityWebApp.Mvc.Models.DownloadListsNewModel
     
    <div>
       <strong>@Html.Raw(Model.Title)</strong>

        @Html.Raw(Model.LibrariesList.Count)
        @foreach (var libraries in Model.LibrariesList )
       {
           <strong>@Html.Raw(libraries.Title)</strong>
    <ul>
         @foreach(var documents in Model.Items)
        {
             if(libraries.Title==documents.Library.Title)
             {
            <li>
                <strong>
                  
                     <a class="sfdownloadTitle" href="@Url.Content( documents.MediaUrl)" target="_blank">@Html.Raw(documents.Title)</a>
                </strong>
                <p>
                    @Html.Raw(documents.Library.Title)
                </p>
            </li>
             }
        }
    </ul>
       }

    </div>

    this is the code


    and in this every files library name is showing only parent library name only if it is in the sub library also

    but i want to display based on its library name as heading

    and how to get the category and tag details of the file

    please help .....
  6. David C
    David C avatar
    33 posts
    Registered:
    02 Dec 2015
    18 Nov 2013
    Link to this post
    Hi Kumar,

    I did a some more research on your question and there's one more step to getting your sub libraries content items. Your sub-libraries are not treated as libraries at all, but are actually organizational folders within your library.  For example:

    Library 1
    SubLibrary 1
    SubLibrary 2
    Library 2
    SubLibrary 3

    Only Library 1 and Library 2 are considered libraries. SubLibrary 1, SubLibrary 2, etc... are considered folders within each library. 

    Take a look at the following documentation, especially item #3, for more info on how to get sub folders and sub items.

    Here's a quick sample of how you could do it in a foreach loop, though.

    foreach(var library in documentLibraries)
    {
    var childItemsUnderFolder = librariesManager.GetChildFolders(library);

    foreach (var subLibrary in childItemsUnderFolder)
    {
    var subLibraryItems = librariesManager.GetAncestorItems(subLibrary);
    }
    }

    From there you will probably have to construct your own libraries and library items list to make it all manageable in your view. 

    Take a look at this forum post about how to get associated taxonomies from a document.

    Regards,
    David C
    Telerik
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
6 posts, 0 answered