SELECT DISTINCT tco.nContentId AS nContentId,tco.cContentKey AS cContentKey,tco.nContentTypeId AS nContentTypeId,tco.cFile AS cContentFile,tco.cFunction AS cContentFunction,tco.cTitle AS cContentTitle,tco.cBody AS cContentBody,tco.dAdded AS dContentAdded,tco.dEdited AS dContentEdited,tco.nTemplateId AS nContentTemplateId,tpc.nTemplateId AS nPageContentTemplateId,tpc.nPageId AS nPageId,tpc.nPageContentId AS nPageContentId,tpc.nTemplateElementId AS nTemplateElementId,ttl.cTemplate AS cContentTemplate,ttp.cTemplate AS cPageContentTemplate,tct.cFile AS cContentTypeFile,tct.cFunction AS cContentTypeFunction,tpg.cTitle AS cPageTitle FROM po_PageContent tpc INNER JOIN po_Pages tpg ON tpg.nPageId=tpc.nPageId INNER JOIN po_Content tco ON tpc.cContentKey=tco.cContentKey INNER JOIN po_ContentType tct ON tco.nContentTypeId=tct.nContentTypeId INNER JOIN po_ContentSecurity tcs ON (tco.nContentTypeId=tcs.nContentTypeId AND tum.nUserTypeId=tcs.nUserTypeId) INNER JOIN po_UserTypeMember tum ON tcs.nUserTypeId=tum.nUserTypeId LEFT OUTER JOIN po_Templates ttl ON tco.nTemplateId=ttl.nTemplateId LEFT OUTER JOIN po_Templates ttp ON tpc.nTemplateId=ttp.nTemplateId WHERE tpg.cPageKey='home' AND tct.cApprovalRequired=tco.cApproved AND tcs.cView='x' AND tum.nUserId=1 AND ( ( tco.dStart<=now() AND tco.dEnd>=now() ) OR (tco.dStart=0 AND tco.dEnd=0) ) ORDER BY tpc.nTemplateElementId,tpc.nIndex