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

Forums / Developing with Sitefinity / Generic Content Provider

Generic Content Provider

6 posts, 1 answered
  1. Drew Greenwell
    Drew Greenwell avatar
    66 posts
    Registered:
    11 Feb 2010
    23 Mar 2010
    Link to this post
    Hey, im going through the process of adding a custom generic provider to sitefinity so i can add metafields to only a specific area of a site, what im reading seems to be very inconsistent and changing alot so im directing this question to here.

    *Ive gotten to the point that I can go to the generic content module, and choose the custom provider from the drop down. When the page refreshes, the alternate control is used, but data from the original content provider is still listed as well and all the added fields show "undefined".  (img attached)
    *Choosing add new content at this point brings me to the page with the control /Admin/ControlTemplates/CustomModuleName/ContentNewView.ascx  My custom fields are exposed here, but filling them out and choosing "Create this Item" shows all blank values for custom meta fields on the rad grid.

    currently reading
    http://www.josephguadagno.net/post/Creating-a-new-Sitefinity-generic-content-module.aspx
    http://www.sitefinity.com/help/developer-manual/products-module-simple-implementation.html
    http://www.sitefinity.com/blogs/ivan/posts/09-03-11/sample_generic_content_based_module_products_module.aspx
    http://www.sitefinity.com/support/kb/sitefinity-3-x/adding-a-custom-provider-for-generic-content.aspx

    Thanks in advance for any help or direction


    In hopes that there is a glaring omission in my process, Here's what ive done to this point..

    added provider to web.config
    <add name="Generic_Content" urlRewriteFormat="[Publication_Date]/[Name].aspx" ... />
    <add name="People" urlRewriteFormat="/people/[Name].aspx" urlDateTimeFormat="yy-MM-dd" urlWhitespaceChar="-" visible="True" defaultMetaField="Name" securityProviderName="" allowLocalization="False" allowVersioning="True" allowWorkflow="true" allowComments="false" commentsModeration="true" versioningProviderName="" connectionStringName="GenericContentConnection" type="Telerik.Cms.Engine.Data.Providers.DefaultProvider, Telerik.Cms.Engine.Data"/>

    added new meta fields for provider
    <add key="People.Name" valueType="ShortText" visible="True" searchable="True" sortable="True" defaultValue="Enter Name"/>       
            <add key="People.JobTitle" valueType="ShortText" visible="True" searchable="True" sortable="True" defaultValue="Job Title Goes Here"/>
            <add key="People.ImageUrl" valueType="ShortText" visible="True" searchable="True" sortable="True" defaultValue=""/>
            <add key="People.Category" valueType="ShortText" visible="True" searchable="True" sortable="True" defaultValue=""/>       
            <add key="People.Ordinal" valueType="Integer" visible="True" searchable="False" sortable="True" defaultValue=""/>


    mapped admin templates to new files for custom provider(first two listed)
    <!--Provides user interface for displaying a list of content items in the Generic Content module.-->
       <viewSettings hostType="Telerik.Cms.Engine.WebControls.Admin.ContentItemsList`1[[Telerik.Cms.Engine.WebControls.Admin.ContentItemsView, Telerik.Cms.Engine]]">
         <additionalTemplates>
           <add key="People" layoutTemplatePath="~/Sitefinity/Admin/ControlTemplates/People/ContentItemsList.ascx" />
         </additionalTemplates>
       </viewSettings>
       <!--Provides user interface for previewing a content item in the Generic Content module.-->
       <viewSettings hostType="Telerik.Cms.Engine.WebControls.Admin.ContentItemPreview`1[[Telerik.Cms.Engine.WebControls.Admin.ContentItemsView, Telerik.Cms.Engine]]">
         <additionalTemplates>
           <add key="People" layoutTemplatePath="~/Sitefinity/Admin/ControlTemplates/People/ContentPreview.ascx" />
         </additionalTemplates>
       </viewSettings>


    Edited templates to expose new meta fields
    <h3><asp:Label ID="Label1" AssociatedControlID="ImageUrl" runat="server">
               <asp:Literal ID="Literal2" runat="server" Text="ImageUrl"></asp:Literal>
               * <em id="Em2" runat="server"></em>
           </asp:Label></h3>
           <fieldset class="set">
               <div class="setIn">
                   <asp:TextBox ID="ImageUrl" Text="" runat="server"></asp:TextBox>
                   <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="ImageUrl" Display="Dynamic" EnableViewState="False" CssClass="validMessage" SetFocusOnError="True"><strong><asp:Literal ID="Literal1" runat="server" Text="ImageUrl must not be empty"></asp:Literal></strong></asp:RequiredFieldValidator>
               </div>
           </fieldset>
            <h3><asp:Label ID="Label2" AssociatedControlID="JobTitle" runat="server">
               <asp:Literal ID="Literal3" runat="server" Text="JobTitle"></asp:Literal>
               * <em id="Em3" runat="server"></em>
           </asp:Label></h3>
           <fieldset class="set">
               <div class="setIn">
                   <asp:TextBox ID="JobTitle" Text="" runat="server"></asp:TextBox>
                   <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="JobTitle" Display="Dynamic" EnableViewState="False" CssClass="validMessage" SetFocusOnError="True"><strong><asp:Literal ID="Literal4" runat="server" Text="Job title must not be empty"></asp:Literal></strong></asp:RequiredFieldValidator>
               </div>
           </fieldset>
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    23 Mar 2010
    Link to this post
    Hello Drew Greenwell,

    *Ive gotten to the point that I can go to the generic content module, and choose the custom provider from the drop down. When the page refreshes, the alternate control is used, but data from the original content provider is still listed as well and all the added fields show "undefined".  (img attached)

    The columns Path to Image, Job Title, Ordinal are Status are not default fields for any module that we ship with Sitefinity. So, the value that you should see depending on the data you have used to populate the metakeys for each content and the way that the RadGrid is bound.

    The metakeys should be added inside ContentMetaFields control on ContentItemEdit and ContentItemNew templates. The ContentMetaFields control should have id="MetaFields". If you do not want to use ContentMetaFields control you have to persist the values manually by overriding the SaveContent method of ContentItemEdit class and ContentItemNew class.

    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.
  3. Drew Greenwell
    Drew Greenwell avatar
    66 posts
    Registered:
    11 Feb 2010
    23 Mar 2010
    Link to this post
    Ah I see. Thanks Ivan! So any established meta fields need to go into the  ContentMetaFields controls to be registered, that will work.

    I updated ContentNewView.ascx and ContentEditView.ascx to reference the meta fields from the sf:ContentMetaFields control and that got the add and edit functionality working as expected.  

    My only remaining issue is that Content from both providers is showing up in both list.   So Custom Provider content shows in the default list and Default Provider content also shows in the Custom provider list.  Is there a reason why the current provider isn't being used to filter the radgrid on ContentItemsList.ascx?

    This value is swapping to the correct Provider value, but the list is not filtering accordingly.
    var dataProviderName = "<%= ((Telerik.Cms.Engine.WebControls.Admin.ContentItemsList
    <Telerik.Cms.Engine.WebControls.Admin.ContentItemsView>)Parent.Parent).ProviderName %>";


    The same issue exists for categories but I see that you can explicitly set a ProviderName on the ContentCategoriesField.


    thanks again for your help thus far

    Drew
  4. Drew Greenwell
    Drew Greenwell avatar
    66 posts
    Registered:
    11 Feb 2010
    24 Mar 2010
    Link to this post
    Still havent figured this out, but I thought I would note some strange behavior.. (im on 3.7SP3)

    going to the custom provider list view (ContentItemsList.ascx) is still showing data from all providers.
    sorting the custom provider list by an item that is specific to the custom provider causes only the custom provider items to be displayed in the list

    After  3 sorts, all entries appear again. This pattern is repeatable.

    steps:
    * Choose the custom provider from drop down and all items are displayed including items that shouldnt be(attachment 1)
    * Sort by Any column that is unique to the provider 2 times and only custom items are displayed (attachment 2 = first sort)
    * Sort any column that is unique to the provider 3 times. On the third time results from both providers are displayed again??  

    Its even independent to the column. So I could click each unique column twice and the appropriate data would be returned, but clicking any of them a third time shows all results again

    Is this a bug with new version or am I just missing something obvious?
  5. Drew Greenwell
    Drew Greenwell avatar
    66 posts
    Registered:
    11 Feb 2010
    24 Mar 2010
    Link to this post
    looking further at the post data shows that the correct provider is being posted to the page, but the datalist is still not updated.. Since i've gotten no further responses, Im going to assume that you guys have not continued to read this post since I confirmed part of my problem was resolved.. I guess I should post this as a separate question shortly(even though it's in my original post)

    attached 4 screen shots but they dont seem to be showing up so here's the json post data

    FIRST POST   (DATA FROM BOTH PROVIDERS SHOWING BUT SHOULDN'T BE)
    {"startRowIndex":0,"maximumRows":50,
    "sortExpression":"",
    "filterExpression":"","requiredMetaFields":["Name"
    ,"ImageUrl","JobTitle","Ordinal"],
    "currentCulture":"1033","provider":"People"}


    FIRST SORT  (ONLY CUSTOM PROVIDER DATA)
    {"startRowIndex":0,"maximumRows":50,
    "sortExpression":"JobTitle ASC",
    "filterExpression":"","requiredMetaFields"
    :["Name","ImageUrl","JobTitle","Ordinal"],
    "currentCulture":"1033","provider":"People"}


    SECOND SORT  (ONLY CUSTOM PROVIDER DATA)
    {"startRowIndex":0,"maximumRows":50,
    "sortExpression":"JobTitle DESC",
    "filterExpression":"","requiredMetaFields"
    :["Name","ImageUrl","JobTitle","Ordinal"],
    "currentCulture":"1033","provider":"People"}


    THIRD SORT   (DATA FROM BOTH PROVIDERS SHOWING BUT SHOULDN'T BE)
    {"startRowIndex":0,"maximumRows":50,
    "sortExpression":"","filterExpression":"",
    "requiredMetaFields":["Name"
    ,"ImageUrl","JobTitle","Ordinal"],
    "currentCulture":"1033","provider":"People"}
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    24 Mar 2010
    Link to this post
    Hi Drew Greenwell,

    You got a reply to the other thread you have opened. The response time in forums is 72 hours. Although this you have not received a reply in more than 22 hours.

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