More in this section

Forums / Developing with Sitefinity / Custom List Template?

Custom List Template?

10 posts, 0 answered
  1. Ben
    Ben avatar
    18 posts
    Registered:
    12 May 2008
    07 Jul 2009
    Link to this post
    Browsing the 'advanced' tb for the PageList mode of List control, I see a property named PageListTemplatePath.  This, I assume, will allow me to create custom formatted list entries.  Am I right?
    If so:
    - How do I define a template - is it a .ascx file?
    - Where do I put the template, and can I use the File Upload function to get it where it needs to be?

    Thanks,
            Ben
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    07 Jul 2009
    Link to this post
    Hi Ben,

    PageListTemplatePath is a property of ListDisplay control that will allow you to set a path to a custom template for PageList presentation mode.

    - How do I define a template - is it a .ascx file?
    - Where do I put the template, and can I use the File Upload function to get it where it needs to be?


    There are external templates that you can download from your MyClient account >> Downloads.
    For more detailed information, please take a look at the following articles.

    MapExternalView - note that this article does not apply to controls' presentation modes.
    Working With Presentation Modes

    If you need further assistance, let us know.

    Best wishes,
    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.
  3. andersleet
    andersleet avatar
    155 posts
    Registered:
    03 Jun 2009
    07 Jul 2009
    Link to this post
    Yes, you are correct that you can define custom templates for List Controls...as well as most every other control that comes with SF. This is a screenshot of my project's root, showing where I put my custom templates:


    As you can see, I created a 'Custom' folder inside the root, then I create subfolders inside this folder to keep it organized. This screenshot shows the properties of the search box with the custom template applied:


    So that should answer your questions, templates are usercontrols (ascx files), and can be put pretty much anywhere inside your SF project.

    Cheers,
    anders
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    12 Jul 2009
    Link to this post
    Hi andersleet,

    This is a good approach to keep the templates organized. I used it with my first 3.6 dev project. The only inconvenience that I faced was when using ControlsConfig template to get the hostType of an view I had to change the path instead of directly pasting the viewSettings line.

    Regards,
    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.
  5. Ben
    Ben avatar
    18 posts
    Registered:
    12 May 2008
    13 Jul 2009
    Link to this post
    Ivan,
       This is a good start, and it leads me to my next question.  I want my list to have a custom data source (we need to do some sorting before displaying the results).  I see a CustomDataSource property, which is what (I assume) I use to identify my new datasource.
    1 - for an expandable list control, what fields (column names) do I need to provide in my datasource?
    2 - will an ObjectDataSource suffice?
    3 - How do I access the custom datasource - create a DLL with the datasource in it, upload the dll, ???
    Thanks,
        Ben
  6. andersleet
    andersleet avatar
    155 posts
    Registered:
    03 Jun 2009
    13 Jul 2009
    Link to this post
    Hey Ben,

    For my custom module I used a Linq to SQL data source. I put this inside my App_Code\<module name> folder. After you do this, make sure you restart your webserver (this hung me up for a good while) then you should be able to see your data source when you are working with your code-behind. Although, this is all assuming you are working with the codebehind. From the sound of your last post (in my head, anyway) it looks like you just want to drop the control on the page and set the data source in the control's Edit > Advanced menu (correct me if I am wrong).

    As for columns, you will have to specify the ones you want to display on your list control. For instance, my table's column names are: id, name, type, url, stateid. I only wanted the name, type and stateid so those are the ones I specified. For the datasource itself, I would have all of your table's columns in there (unless you aren't going to be using specific ones at all) so you can always have access to those values inside your code.

    Hopefully some of this information helps!

    Regards,
    anders
  7. Ben
    Ben avatar
    18 posts
    Registered:
    12 May 2008
    13 Jul 2009
    Link to this post
    A bit closer with each step.
    I've created a DLL with the desired namespace / class / method.  I've tried to put <namespace>.<class>.<method> in the CustomDataSource property, I've left the Provider set to 'Sitefinity' (which ls also the connectionString name), and I've tried with and without the list specified as a property.  I'm not getting the correct data, and when I return to re-edit the properties for the control, the CustomDataSource property has been cleared.
    It is possible to create a datasource and point to it via the control's control designer?  How is this done?
       Ben
  8. andersleet
    andersleet avatar
    155 posts
    Registered:
    03 Jun 2009
    13 Jul 2009
    Link to this post
    Just something to try:

    Assuming that you are setting the datasource via the Edit > Advanced menu of the control, one thing that has hung me up is just typing in a value is not enough. Try putting the value in then pressing enter afterwords. It will look like the page refreshes for a split second but you won't see any differences. After you have done this, click done and see if that works.

    Cheers,
    anders
  9. homepagedigital
    homepagedigital avatar
    13 posts
    Registered:
    06 Jul 2009
    14 Oct 2009
    Link to this post
    Hi

    I too have a folder off root for custom templates.

    When I select my template to go into the appearance field 'SingleItemTemplatePath' it does not stick. i.e. I click I'm done then publish - no change is seen. I go back into appearance and notice that the original path has replaced my selected path.

    What is happening here, any help appreciated?

    Jo
  10. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    14 Oct 2009
    Link to this post
    Hi homepagedigital,

    I am not able to reproduce this problem using the last official release of Sitefinity - 3.7 SP1. The SingleItemTemplatePath property is correctly persisted. Attached is a test video.

    Kind regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Register for webinar
10 posts, 0 answered