Site Cultre

Devwork AL asked on July 25, 2021 16:22


Where is the Culture code used in sql statements generated by ObjectQuery API and the PageRetriever API obtained? My localhost and live server are showing different values for the @DocumentCulture for the same query.

Localhost : en-US live : en-SG (en-SG is not one of the locales listed in the culture settings) The Site settings shows the same values for both localhost and live server.

This is the SQL I got :

DECLARE @Value nvarchar(max) = N'2020'; 
DECLARE @NodeSiteID int = 1; 
DECLARE @Now datetime2 = '7/25/2021 10:09:35 PM'; 
DECLARE @DocumentCulture nvarchar(max) = N'en-US'; 

WITH AllData AS ( SELECT *, ROW_NUMBER() OVER (ORDER BY [displayDate] DESC) AS [CMS_RN] FROM View_CMS_Tree_Joined AS V WITH (NOLOCK, NOEXPAND) INNER JOIN TF_MediaReleases AS C WITH (NOLOCK) ON [V].[DocumentForeignKeyValue] = [C].[MediaReleasesID] AND V.ClassName = N'TF.MediaReleases' LEFT OUTER JOIN COM_SKU AS S WITH (NOLOCK) ON [V].[NodeSKUID] = [S].[SKUID] WHERE YEAR(displayDate) = @Value AND [NodeSiteID] = @NodeSiteID AND (([DocumentCanBePublished] = 1 AND ([DocumentPublishFrom] IS NULL OR [DocumentPublishFrom] <= @Now) AND ([DocumentPublishTo] IS NULL OR [DocumentPublishTo] >= @Now)) AND [DocumentCulture] = @DocumentCulture) ) SELECT *, (SELECT COUNT(*) FROM AllData) AS [CMS_TOT] FROM AllData WHERE CMS_RN BETWEEN 11 AND 20 ORDER BY CMS_RN

From these codes

var mediaReleases = MediaReleasesProvider.GetMediaReleases()
                .WhereEquals("YEAR(displayDate)", year)
                .Page(pageIndex, pageSize);


Correct Answer

Sean Wright answered on July 27, 2021 03:57

The culture is determined by the association of the request URL/Domain with the settings configured in the application that determine how to identify the correct culture.

There's also a CMS setting that determines whether or not the PageRetriever automatically gets results for the default site culture if none are available for the request's culture.

0 votesVote for this answer Unmark Correct answer

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