Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at

  • MuirisOG 294 posts 1020 karma points
    May 18, 2017 @ 17:17

    ContentTypeService GetContentOfContentType

    Dear all

    I've got some code which I've realised isn't working correctly.

    It was supposed to get me all content of a particular document type, but it doesn't get everything.

    Excuse the code but any help is appreciated.

    I'm on v7.5.13, importing pages from an older CMS, and yes, the missing pages have been correctly assigned the doctype I'm looking for.

    Note that I've switched off the XML cache due to the size of my site.

                Dim cs As IContentService = ApplicationContext.Current.Services.ContentService
                Dim cts As IContentTypeService = ApplicationContext.Current.Services.ContentTypeService
                Dim dt As Integer = cts.GetContentType("myDocType").Id
                Dim d As IEnumerable(Of IContent)
                d = cs.GetContentOfContentType(dt)
                    For Each doc As IContent In d
                        'some processing takes place here
                        'with the doc.Id etc, i.e. I'm adding the Id to a hashtable
                Catch ex As Exception
                    'exception handling
                End Try
  • MuirisOG 294 posts 1020 karma points
    May 19, 2017 @ 11:15

    Apologies, I'm being an idiot (again).

    The For Each loop that built the hash table was bombing out on duplicates, something I had fixed but managed to unfix.



    EDIT: ... and the Try Catch should have been inside the loop, at the point where the hash table was being added to.

Please Sign in or register to post replies

Write your reply to: