|
| Getting the BlogGroupID from the current CSContext |
 |
Sat, 23 Sep 2006 11:10:08 +000 |
I am trying to do a Server Control that needs to be aware of the current blogs
BlogGroupID. So if the control is put in i.e the Skin-BlogSideBar.ascx, the
control should know which BlogGroupID the current blog belongs to.
I have been using CSContext.Current.BlogGroupID for that, but it seems to give
me a value of -1 regardless of which blog I go to. Is there a different way I
should do this?
|
| Post Reply
|
| Re: Getting the BlogGroupID from the current CSContext |
 |
Mon, 25 Sep 2006 16:45:22 +000 |
The code in BaseBlogPage, that looks up the "current" blog is:
protected virtual Weblog WeblogLookUp()
{
if(_weblog == null)
{
CSContext context = CSContext.Current;
if(context.SectionID > 0)
{
_weblog = Weblogs.GetWeblog(context.SectionID,true,false);
SetCookie(_weblog);
}
else
{
HttpCookie cookie =
context.Context.Request.Cookies[CreateApplicationCookieName(context,"weblog
")];
if(cookie != null)
{
if(!Globals.IsNullorEmpty(cookie.Values["BlogID"]))
{
int bid =
Int32.Parse(cookie.Values["BlogID"]);
try
{
_weblog = Weblogs.GetWeblog(bid,true,false);
}
catch{}
}
}
}
if(_weblog == null)
{
ArrayList blogs = Weblogs.GetWeblogs(true,false,false);
blogs =
Sections.FilterByAccessControl(blogs,Permission.Post,context.User);
if(blogs != null && blogs.Count == 1)
{
_weblog = blogs[0] as Weblog;
SetCookie(_weblog);
}
}
if(_weblog == null)
Response.Redirect("switch.aspx");
}
return _weblog;
}
And from there you can query the GroupID of the blog.
|
| Post Reply
|
| Re: Getting the BlogGroupID from the current CSContext |
 |
Mon, 25 Sep 2006 17:23:17 +000 |
I am not sure what you mean, I am not going to edit the source code, but are
going to query the API, in this case CSContext.Current.BlogGroupID to get the
blogID.
The question is, is there a way to use the CSContext class to get the blog group
of the current blog?
|
| Post Reply
|
| Re: Getting the BlogGroupID from the current CSContext |
 |
Mon, 25 Sep 2006 18:50:41 +000 |
Is your control being used on a Blog page?
Is your control inheriting WeblogThemedControl?
|
| Post Reply
|
| Re: Getting the BlogGroupID from the current CSContext |
 |
Mon, 25 Sep 2006 19:26:08 +000 |
In WeblogTemplatedWebControl the following code gets the current blog from
CSContext.Current.
string appKey = CSContext.Current.ApplicationKey;
if(appKey == null)
appKey = WeblogConfig.DefautApplicationKey;
weblog = Weblogs.GetWeblog(appKey,true);
BlogGroupID in CSContext is just an alias for
Request.QueryString["blogGroupID"], which returns -1 if no
querystring/ value is present.
|
| Post Reply
|
|
|
|
|
|
|
|
|
|