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

Forums / Suggestions / Templates base controls

Templates base controls

4 posts, 0 answered
  1. SelAromDotNet
    SelAromDotNet avatar
    912 posts
    Registered:
    18 Jul 2012
    23 Jul 2009
    Link to this post
    I think it would be helpful if, isntead of inheriting from UserControl, the generic content templates (newsmasterview, newsdetailsview, eventsmasterview, etc) would inherit from something like ContentViewControl, where each control would have a strongly-typed propery that holds the contentitem in question.

    For example, if I'm on the newsview, and want to retrieve properties from the newsitem, I have to call the NewsManager and retrieve this item again. This is redundant, because the control already has this item, as it's using it to populate the page. However, it's not accessible at the page level.

    It would be great if we could be in the NewsView and do something like

    MyCustomLabel.Text = this.ContentItem.GetMetaData("MyCustomField")

    where ContentItem is the IContent item retrieved when the control is initialized.

    I hope that this makes sense, and if such feature is already present, please point it out to me as this would save me tons of time!

    thanks
  2. Parvan
    Parvan avatar
    151 posts
    Registered:
    24 Sep 2012
    28 Jul 2009
    Link to this post
    Hello SelArom,

    There is a way you can reuse the IContent item from the ContentView based controls(NewsView, EventsView).
    You need to override the method SetSingleItemContent:

    protected override void SetSingleItemContent(IContent item) 
        base. SetSingleItemContent(item); 
    // do your job here 
     


    I hope this helps you

    Kind regards,
    Parvan
    the Telerik team

    Instantly find answers to your questions on the newTelerik Support Portal.
    Check out the tipsfor optimizing your support resource searches.
  3. SelAromDotNet
    SelAromDotNet avatar
    912 posts
    Registered:
    18 Jul 2012
    28 Jul 2009
    Link to this post
    thanks for your reply! but it looks like this is at the contentview control level. I don't want to change that file because then I'll have to register my overridden control.

    what I'm referring to is the usercontrol templates that are used to layout the control. currently, these are regular user controls, with no embedded, strongly typed property to reference the contentview.

    I think I could inherit from UserControl and add a property that does something like

    protected IContent ContentItem
    { get
    {
        // use reflection to get embedded content item
    }
    }

    but it would be better if this was automatically part of the system, so that whenever I map to a user control, i map to a usercontrol of type IContentUsercontrol or something similar that already includes this property.

    i hope that makes sense! thanks for listening
  4. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    31 Jul 2009
    Link to this post
    Hi SelArom,

    Thank you for the additional details.
    The behavior you see in the moment is pretty much depending on the ORM used. With Nolics and this architecture, you should start a new transaction every time you want to get an item. Otherwise you will get the familiar object not in transaction error. The transaction ends right after we show the item together with its meta fields.

    In Sitefinity 4.0 the approach would be rather different though. We are focused on the performance and strengthening the API. In the upcoming version for example, there will be a case in which even the transactions will be kept in cache as well as the database write operations, so this will allow a huge lower with minimum database operations. Back to the question - the work with the managers will be completely different, and you will not need to take the items again. We will think for your suggestion as well, and provide an easier access to the content.

    All the best,
    Georgi
    the Telerik team

    Instantly find answers to your questions on the newTelerik Support Portal.
    Check out the tipsfor optimizing your support resource searches.
Register for webinar
4 posts, 0 answered