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

Forums / Module Builder / Problem retrieving data collection in Module Builder

Problem retrieving data collection in Module Builder

2 posts, 0 answered
  1. Jimmy
    Jimmy avatar
    7 posts
    Registered:
    23 Apr 2012
    08 Apr 2013
    Link to this post
    Hi,

    I have created a custom module using Module Builder. I use the following code to return collection.
    // Gets a collection of "live" and "visible" employee items.
    protected IQueryable<DynamicContent> GetDataItems()
    {
        DynamicModuleManager dynamicModuleManager = DynamicModuleManager.GetManager();
        Type employeeType = TypeResolutionService.ResolveType("Telerik.Sitefinity.DynamicTypes.Model.Employees.Employee");
      
        // Fetch a collection of "live" and "visible" employee items.
        var myCollection = dynamicModuleManager.GetDataItems(employeeType)
            .Where(i => i.Status == Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Live && i.Visible == true);
      
        return myCollection;
    }

    For some reason, when I am logged in, the function returns six items in the collection, but when I am logged out, it returns 0 item in the collection (myColloection.Count() = 0, and dynamicModuleManager.GetDataItems(employeeType).Count = 0).

    I want the function to return six items even I am not logged in. Please help.

    Thanks,
    Jimmy 



  2. Craig
    Craig avatar
    82 posts
    Registered:
    07 Apr 2009
    08 Apr 2013 in reply to Jimmy
    Link to this post
    By default dynamic modules permissions are set to be only accessible to administrators.  Check your permissions for this module.

    Also, you can suppress security checks.  Before you run your code to retrieve the items just set SuppressSecurityChecks to TRUE and then after you are done, set it back to FALSE.

    dynamicModuleManager.Provider.SuppressSecurityChecks = true;

    Also, here is another post that demonstrates this concept.

    http://www.sitefinity.com/developer-network/forums/developing-with-sitefinity-/concurrent-cms-user-and-custom-control

    Hopefully this will help.

    Craig
2 posts, 0 answered