Hi Dan,

For a sub site should I be using PublishingWeb instead?

Would something like this work?

if (!currentPublishingSite.IsRoot && 
currentPublishingWeb.Title.ToLower().Equals("news"))
{
                // Do stuff...


From: ozmoss-boun...@ozmoss.com [mailto:ozmoss-boun...@ozmoss.com] On Behalf Of 
Paul Noone
Sent: Thursday, 9 June 2011 8:47 AM
To: ozMOSS
Subject: RE: 2007 - currentPublishingSite

Wouldn't you use currentPublishingSite.Title?

Beats the heck out of me. That's why I'm asking. :)

Without fully seeing what your trying to do... I assume you passing in 
currentPublishingSite, checking if it's a root, if not, see if it's a news 
site? In which case the SPContenxt may not actually contain the news title as 
you may not be on the news site when you run this code?

All sites are created using the same template so I'm not trying to target a 
particular template ID. The feature receiver will run when any site is created. 
What I'm attempting to do is supply additional configurations if the name of 
the newly created sub site is "news". Given that the receiver runs after the 
initial creation process I'm hoping this is possible.

I will try using currentPublishingSite.Title and see if it has better luck.

From: ozmoss-boun...@ozmoss.com [mailto:ozmoss-boun...@ozmoss.com] On Behalf Of 
Paul Noone
Sent: Wednesday, 8 June 2011 3:36 PM
To: ozMOSS
Subject: RE: 2007 - currentPublishingSite

Unfortunately this check still fails to identify the name of the web. This 
function is part of a feature receiver at site creation.

I'm wondering whether it's unable to get the name of the web this early?

Any advice appreciated.

private void CreateSampleContentPage(PublishingWeb currentPublishingSite)
      {
         SPContentTypeId pageContentTypeId;
         string pageLayoutName;
         string pageName;
         string pageTitle;

         if (currentPublishingSite.IsRoot)
         {
            pageContentTypeId = _welcomePageContentTypeId;
            pageLayoutName = _defaultWelcomePageLayoutName;
            pageName = _defaultWelcomePageName;
            pageTitle = _defaultWelcomePageTitle;
         }
         // News site [3]
         else if (SPContext.Current.Web.Title.ToLower().Equals("news"))
         {
             pageContentTypeId = _ceoPageContentTypeId;
             pageLayoutName = _defaultceoPageLayoutName;
             pageName = _defaultceoPageName;
             pageTitle = _defaultNewsArticleTitle;
         }
         else
         {
          ...


From: ozmoss-boun...@ozmoss.com [mailto:ozmoss-boun...@ozmoss.com] On Behalf Of 
Paul Noone
Sent: Tuesday, 7 June 2011 11:49 AM
To: ozMOSS
Subject: RE: 2007 - currentPublishingSite

Sweet. I was that close. ;)

Thanks Dan.

From: ozmoss-boun...@ozmoss.com [mailto:ozmoss-boun...@ozmoss.com] On Behalf Of 
Daniel Brown
Sent: Tuesday, 7 June 2011 10:58 AM
To: 'ozMOSS'
Subject: RE: 2007 - currentPublishingSite

SPContext.Current.Web.Title

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spweb.title.aspx


However, I'd do something like.

if (SPContext.Current.Web.Title.ToLower() == "news")
{
// do something here
}


Alternatively

if (SPContext.Current.Web.Title.ToLower().Equals("news"))
{
// do something here
}



From: ozmoss-boun...@ozmoss.com [mailto:ozmoss-boun...@ozmoss.com] On Behalf Of 
Dan Sheedy
Sent: Tuesday, 7 June 2011 10:23 AM
To: ozMOSS
Subject: Re: 2007 - currentPublishingSite

Hey Paul.

I think you can test the current web title with;

if (SPContext.Current.Web.ToString() == "News")
{

}
On Mon, Jun 6, 2011 at 1:34 PM, Paul Noone 
<paul.no...@ceosyd.catholic.edu.au<mailto:paul.no...@ceosyd.catholic.edu.au>> 
wrote:
Hi all,

I am trying to check if the current site's Title (or Name) equals "News" but 
appear to be having some syntax issues. :)

Can someone please point me in the right direction?

if (currentPublishingSite.Title.Equals("News"))

Kind regards,

Paul Noone

---------------------------------------------------
Online Developer/SharePoint Administrator
Infrastructure Team, ICT
Catholic Education Office, Sydney
p: (02) 9568 8461
f: (02) 9568 8483
e: paul.no...@ceosyd.catholic.edu.au<mailto:paul.no...@ceosyd.catholic.edu.au>
w: http://www.ceosyd.catholic.edu.au/


_______________________________________________
ozmoss mailing list
ozmoss@ozmoss.com<mailto:ozmoss@ozmoss.com>
http://prdlxvm0001.codify.net/mailman/listinfo/ozmoss

_______________________________________________
ozmoss mailing list
ozmoss@ozmoss.com
http://prdlxvm0001.codify.net/mailman/listinfo/ozmoss

Reply via email to