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

Forums / Developing with Sitefinity / Extend sitefinity datamodel: custom PageProvider not registered?

Extend sitefinity datamodel: custom PageProvider not registered?

11 posts, 1 answered
  1. Mark
    Mark avatar
    9 posts
    Registered:
    11 Nov 2010
    15 Oct 2014
    Link to this post

    I'm trying to extend the sitefinity data model to allow users to select categories they are interested in. In that way, we can build a custom widget which displays only news content for a registered user which he would like to see.

     In order to accomplish that I've folowed the following tutorial: http://www.sitefinity.com/documentation/documentationarticles/extending-the-sitefinity-model

    In the last step, I need to register the provider in the sitefinity backend. So far so good: the type is recognized and it seems the provider is registered. 

     However, in the custom widget the Provider collection of the pagemanager I'm trying to reach (PageManager.GetManager().Providers) still only contains the default OpenAccessDataProvider.

    Am I on the right track for this approach? How can I get a reference to the new Custom Provider? Any other suggestions?

  2. Svetoslav Manchev
    Svetoslav Manchev avatar
    735 posts
    Registered:
    29 Nov 2016
    20 Oct 2014
    Link to this post
    Hi Mark,

    Normally the code you have provided should returns both provider (default and your custom one).

    Could you please check and ensure that the settings are correct as per that article. Can you attach also a screenshot of the settings you have and the code implemented?

    From other hand, the scenario you have described is covered by Categories/Tags widgets for default and custom classifications and setting the proper permissions for News Items.

    I hope this information helps.

    Regards,
    Svetoslav Manchev
    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 Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
     
  3. Mark
    Mark avatar
    9 posts
    Registered:
    11 Nov 2010
    22 Oct 2014
    Link to this post

    If you have any suggestions how users can filter news by categories themselves without making a new PageProvider and CustomType, please let me know.In the attached files you can see:
    - the settings page for the custom PageProvider (settings.png)
    - a screenshot from the Visual Studio project in the Solution Explorer (project.png)
    - a screenshot during debugging with info about the registered providers (debug.png)

    Kind regards
    Mark

  4. Svetoslav Manchev
    Svetoslav Manchev avatar
    735 posts
    Registered:
    29 Nov 2016
    27 Oct 2014
    Link to this post
    Hello Mark,

    You can easily filter the news using the Categories widget. For example create a Category
    Colours > Red & Blue and add them to the News Items.

    Than drop the News and Categories widget on a Page.

    Short video demonstration how it works could be found here.

    I hope this helps.

    Regards,
    Svetoslav Manchev
    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 Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
     
  5. Mark
    Mark avatar
    9 posts
    Registered:
    11 Nov 2010
    27 Oct 2014 in reply to Svetoslav Manchev
    Link to this post

    Hello Svetoslav,

    Thanxs for your reply. However, I do not want the admin user to filter the news based on the categories, but the end users of the website themselves. For each user, the news widget must show the news items filtered on the categories which the end user is interested in.

    Any suggestions why the PageProvider is'nt registered?

  6. Svetoslav Manchev
    Svetoslav Manchev avatar
    735 posts
    Registered:
    29 Nov 2016
    27 Oct 2014
    Link to this post
    Hi Mark,

    The List of News and the filtering was done on the frontend.

    So the end users will filter the News by the categories available. The last 10 seconds of the video are on frontend page.

    Regards,
    Svetoslav Manchev
    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 Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
     
  7. Mark
    Mark avatar
    9 posts
    Registered:
    11 Nov 2010
    27 Oct 2014 in reply to Svetoslav Manchev
    Link to this post

    Hello,

     I've watched the video a few times, it's rather quick and therefor a bit hard to understand. I see what you mean, the end user can switch between categories to display the related news items. 

     The difference between this approach and the requirements I'm trying to implement is that the end user has to be able to select categories up front, in his profile. A news widget must display the items from a category based on this profile. So for each user, the news widget will contain different news items.

    At this point, the user cannot change categories to display other news items. He must return to his profile page to change his preferences.

     Kind regards,

    Mark     

  8. Svetoslav Manchev
    Svetoslav Manchev avatar
    735 posts
    Registered:
    29 Nov 2016
    30 Oct 2014
    Link to this post
    Hi Mark,

    In order to propose possible solution, would you please elaborate a little more about the scenario that you want to achieve?

    Regards,
    Svetoslav Manchev
    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 Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
     
  9. Mark
    Mark avatar
    9 posts
    Registered:
    11 Nov 2010
    30 Oct 2014 in reply to Svetoslav Manchev
    Link to this post

    I want a news widget on a page which shows news items personalized for each registered user.

    In order to acchieve this, I need registered users to select which categories they are interested in. For this purpose, I have implemented a user profile widget where the users can change their profile, but also can check/uncheck categories in a TreeView. I need to extend the database to store the checked categories per registered user.

    Second, I will need a news widget which reads the preferred categories for the current user and displays only the news items in those categories.

    Kind regards,
    Mark van der Kolk

    PS. Still no answer to my original question, why is the PageProvider not registered?     

  10. Svetoslav Manchev
    Svetoslav Manchev avatar
    735 posts
    Registered:
    29 Nov 2016
    04 Nov 2014
    Link to this post
    Hi Mark,

    We have answer you in the opened support ticket.

    Once you have the solution you can share it with the community.

    Regards,
    Svetoslav Manchev
    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 Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
     
  11. Sabrie Nedzhip
    Sabrie Nedzhip avatar
    534 posts
    Registered:
    02 Dec 2016
    10 Nov 2014
    Link to this post
    Hello Mark,

    Since the solution I have suggested in the support ticket has helped to achieved the desired functionality, I would like to share it with the community. Here is the reply from the support ticket you have opened:

    What I can suggest in order to achieve the desired behavior is to create a custom classification (categories) field in your user profile where you can store the categories selected by the user. 

    Then in the BtnSave_Click() method of your custom user profile widget you can first get the list of categories ids from the user profile of the current user, then add to this list for example the new category selected by the user, and set the value of the custom categories field to the updated categories list. Here is a sample code for your convenience demonstrating how to set the value of the custom categories field (please refer to the code marked in yellow):

    public static MembershipCreateStatus CreateUser(string username, string password, string firstName, string lastName, string mail, string secretQuestion, string secretAnswer, bool isApproved)
            {
                UserManager userManager = UserManager.GetManager();
                UserProfileManager profileManager = UserProfileManager.GetManager();
       
                System.Web.Security.MembershipCreateStatus status;
       
                User user = userManager.CreateUser(username, password, mail, secretQuestion, secretAnswer, isApproved, null, out status);
       
                if (status == MembershipCreateStatus.Success)
                {
                    SitefinityProfile sfProfile = profileManager.CreateProfile(user, Guid.NewGuid(), typeof(SitefinityProfile)) as SitefinityProfile;
       
                    if (sfProfile != null)
                    {
                        sfProfile.FirstName = firstName;
                        sfProfile.LastName = lastName;
       
       
                        // Get the category
                        var category = GetCategoryByName("admins");
       
                        // Get a list of the categories in the user profile, add the new category, then add the list of categories into the profile.
                        var catlist = sfProfile.GetValue<TrackedList<Guid>>("Category");
                        catlist.Add(category.Id);
                        sfProfile.SetValue("Category",catlist);
                    }
       
                    userManager.SaveChanges();
                    profileManager.RecompileItemUrls(sfProfile);
                    profileManager.SaveChanges();
       
                }
       
                return status;
            }
       
            public static Taxon GetCategoryByName(string name)
            {
                TaxonomyManager taxonomyManager = TaxonomyManager.GetManager();
       
                HierarchicalTaxonomy category = taxonomyManager.GetTaxonomy<HierarchicalTaxonomy>(TaxonomyManager.CategoriesTaxonomyId);
       
                if (category == null)
                {
                    return null;
                }
       
                return category.Taxa.Where(t => t.Name == name).SingleOrDefault();
            }

    You can use the code above as a sample and apply it to your custom code. 

    Then, in the custom news widget you get the selected categories from the user profile of the current user:

    var catlist = sfProfile.GetValue<TrackedList<Guid>>("Category");

    and filter the news items by the selected categories.

    I hope that the above suggestion will help you to achieve the desired scenario. Please do not hesitate to get back to me if you need any further assistance.

     
    Regards,
    Sabrie Nedzhip
    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 Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
     
    Answered
11 posts, 1 answered