GetDocuments - for content only page?

Tom F asked on December 15, 2016 02:09

Hi I'm making a call in my .master page codebehind to retrieve a collection of content only pages: "BCS.Testimonial"

I'm loading in the node like so:

var testimonials = DocumentHelper.GetDocuments("BCS.Testimonial").OnCurrentSite();

and it doesn't return anything my tree structure is like

Root - Home - About - < Collection of BCS.Testimonial types >

Thanks

Correct Answer

Anton Grekhovodov answered on December 15, 2016 07:55

Hi Tom,

It must work,

Try to debug this statement to watch what SQL query is executed and execute it manually in DB.

Working example for CMS.MenuItem page type:

var menuItems = DocumentHelper.GetDocuments("CMS.MenuItem").OnCurrentSite();

is converted to:

exec sp_executesql N'SELECT *
FROM View_CMS_Tree_Joined AS V WITH (NOLOCK, NOEXPAND) 
INNER JOIN CONTENT_MenuItem AS C WITH (NOLOCK)
 ON [V].[DocumentForeignKeyValue] = [C].[MenuItemID] AND V.ClassName = N''CMS.MenuItem'' 
LEFT OUTER JOIN COM_SKU AS S WITH (NOLOCK) ON [V].[NodeSKUID] = [S].[SKUID]
WHERE [NodeSiteID] = @NodeSiteID AND [DocumentCulture] = @DocumentCulture',
N'@NodeSiteID int,@DocumentCulture nvarchar(5)', @NodeSiteID=1,@DocumentCulture=N'en-US'
1 votesVote for this answer Unmark Correct answer

Recent Answers


Dragoljub Ilic answered on December 15, 2016 13:11

Hi Tom, If you are using multilingual site, and you didn't specified default culture, then you won't get any page. Try to set default culture for site, or add aditional culture parameters in query, f.e. :

var testimonials = DocumentHelper.GetDocuments("BCS.Testimonial").Culture("en-US").OnCurrentSite();
1 votesVote for this answer Mark as a Correct answer

Tom F answered on December 16, 2016 00:36

Thaks so much for the responses! it appears if you don't specify the class name in getdocuments and instead use

DocumentHelper.GetDocuments().Where(d => d.something) etc it doesn't load related column data :)

Thanks for your time guys :)

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.