DNN Blog

Dec 14

Posted by: Peter Donker
12/14/2009  RssIcon

Because the PortalName has been moved out of the Portals table it is no longer accessible. I worked around this with the following SPROC to get my own portalinfo:

CREATE PROCEDURE {databaseOwner}{objectQualifier}MyGetPortal
@PortalId INT,
@Locale NVARCHAR(6)
AS

DECLARE @DNNVersion INT
SET @DNNVersion = (SELECT MAX(v) FROM
(SELECT Major * 10000 + Minor * 100 + Build AS v FROM {databaseOwner}{objectQualifier}Version) AS x)
IF @DNNVersion > 50200
BEGIN
  IF EXISTS(SELECT * FROM {databaseOwner}{objectQualifier}PortalLocalization WHERE PortalId=@PortalId AND CultureCode=@Locale)
  SELECT * FROM {databaseOwner}{objectQualifier}Portals p
   INNER JOIN {databaseOwner}{objectQualifier}PortalLocalization pl ON p.PortalId=pl.PortalId
   WHERE p.PortalId=@PortalId
   AND pl.CultureCode=@Locale
  ELSE
  SELECT * FROM {databaseOwner}{objectQualifier}Portals p
   INNER JOIN {databaseOwner}{objectQualifier}PortalLocalization pl ON p.PortalId=pl.PortalId
   WHERE p.PortalId=@PortalId
   AND pl.CultureCode=p.DefaultLanguage
END
ELSE
BEGIN
  SELECT * FROM {databaseOwner}{objectQualifier}Portals
   WHERE PortalId=@PortalId
END
GO

 

One could add a default for the @Locale even … but I didn’t need it myself. I tested this on a 5.1.4 and it worked without throwing an error.

EDIT: Just goes to show one cannot know enough of the framework. Cathal was nice enough to point out that I missed vw_Portals. Just goes to show that one should always check the views that are available in SQL as well. So discard the above in favor of:

CREATE PROCEDURE {databaseOwner}{objectQualifier}MyGetPortal
@PortalId INT
AS

SELECT * FROM {databaseOwner}{objectQualifier}vw_Portals p 
WHERE p.PortalId=@PortalId
GO

Quite a bit shorter, eh? Mind you, the locale is lost in this. So if you really need a localized PortalInfo with backward compatibility you’d probably still want the one above.

Tags:
Categories:
Location: Blogs Parent Separator Peter Donker

2 comment(s) so far...


Gravatar

Re: Getting a PortalInfo for both DNN 5.2+ and old versions of DNN

Won't that fail during the module install if the table does not exist? Or is it smart enough to catch the fact that the table is in a IF EXISTS statement and won't validate the table name?

By jsheely on   12/14/2009
Gravatar

Re: Getting a PortalInfo for both DNN 5.2+ and old versions of DNN

In my tests it was smart enough. Note I'm on SQL 2005. Can't speak for SQL 2000. But then ... who still uses that?

By Peter Donker on   12/14/2009
Attend A Webinar
Free Demo Site
Download DotNetNuke Professional Edition Trial
Have Someone Contact Me
Have Someone Contact Me
Charlotte DoDNN

Like Us on Facebook Join our Network on LinkedIn Follow DNN Corporate on Twitter Follow DNN on Twitter

Advertisers

Telerik JustCode Free
Exact Target Exec Alert
PowerDNN

Sponsors

DotNetNuke Corporation

DotNetNuke Corp. is the steward of the DotNetNuke open source project, the most widely adopted Web Content Management Platform for building web sites and web applications on Microsoft. Organizations use DotNetNuke to quickly develop and deploy interactive and dynamic web sites, intranets, extranets and web applications. The DotNetNuke platform is available in a free Community and subscription-based Professional and Enterprise Editions with an Elite Support option. DotNetNuke Corp. also operates the DotNetNuke Store where users purchase third party apps for the platform.