exclude category from page? (and other issue with dynamic height)

Topics: ASP.NET 2.0, Business Logic Layer, Controls
Jan 19, 2010 at 11:43 PM

The hard coding for category specific page works great but now I need to exclude that category from the main page.

Blog/category/My-Category.aspx  is fine for those specific pages but do I have to generate main page using all other categories or can I exclude it from page somehow (either solution would be just as unknown for me at this point).

I could probably modify categorylist.cs somehow from app folder/controls, but after perusing not sure how to do that... is that my only option?  I would have to modify and put that in code behind page load event??  That appears do-able but I am not sure how BE cs code works... any help?

Oh and Part 2 of my question (not related but also an issue I am stuggling with)

I have this site embedded within another ASP.net 2.0  application, and it is within an iFrame so I can use my custom Flash / Flex menu - I am passing variables with javascript to omit need for page refreshes....  However, BE is dynamic and page height is not static by a long shot as far as I can tell, but iFrame is server based and does not recognize dynamics of height when set to 100% so I am trying to go around that and load the iFrame dynamically and set height using javascript but I have not been able to do that so far.  Are there any other ideas??  Or, perhaps better ways??

Thanks so much!

CS

Jan 20, 2010 at 3:34 AM

Answering my own question (sort of regrading the dynamic iframes) there is a javascript function to re-size iframe based on finding a control during page load... that solution is here

http://www.mattcutts.com/blog/iframe-height-scrollbar-example/

 

The other question about exclusing a category of blogs from the main page of blog would still be very interesting if anyone knows a way to do this !!

CS

Coordinator
Jan 20, 2010 at 5:18 AM

As you suggested, you can modify the CategoryList.cs file in the App_Code\Controls folder so it excludes certain categories from appearing in the Category List.  Here's a modified version of the "SortCategories" function that excludes 2 categories (as an example) ...

private SortedDictionary<string, Guid> SortCategories()
{
	SortedDictionary<string, Guid> dic = new SortedDictionary<string, Guid>();
	foreach (Category cat in Category.Categories)
	{
		if (HasPosts(cat))
		{
			if (cat.Title != "Category 1 to Exclude" && cat.Title != "Category2 to Exclude")
			{
				dic.Add(cat.CompleteTitle(), cat.Id);
			}
		}
	}

	return dic;
}

Jan 20, 2010 at 3:37 PM

Ben, thank you so much.  As I begin to understand the vernacular of the classes and how you are using them I will hopefully catch on.  You all are GREAT at answering questions.
Craig

 

 

Jan 20, 2010 at 6:15 PM

Hey Ben,

Quick Question:  Regarding the ability to exclude specific category or categories from a page... (Solution A)

Because controllist.aspx specifies categories to list, if I modify it to exclude a category then I would have to then create a category for ALL entries that is generic, then call that category to get all entries minus the one that I exclude from the categorilist.aspx call when that category is selected, correct?  That seems like the only way it would work...  Otherwise I would get category specific pages minus the ones I exclude.  If I did this I could add a Category update to the addentry.aspx.cs page programmatically, BUT I would have to then modify the Category control so that the user could not deselect that category... (seem like a lot of work), but may be only solution if below does not work.. ** Solution B

Solution B:  What if... I could modify the default.aspx.cs page so that....

     if (Request.RawUrl.ToLowerInvariant().Contains("/categorymain/"))
        {
            DisplayCategoriesMain();         // changing this from DisplayCategory()
        }

private void DisplayCategoriesMain()      //   I added this exactly like DisplayCategory()
    {
        if (!String.IsNullOrEmpty(Request.QueryString["id"]))
        {
            Guid categoryId = new Guid(Request.QueryString["id"]);
            PostList1.Posts = Post.GetPostsByCategory(  <INSERT CODE HERE CATEGORYID != "VALUE">  ).ConvertAll(new Converter<Post, IPublishable>(delegate(Post p) { return p as IPublishable; }));
            Page.Title = Category.GetCategory(categoryId).Title;
        }
    }

However, I can not get it to work, in fact, if I try to use a querystring ie..  "  /default.aspx?id=categoryname  "  it does not work... so how does this function on Default.aspx.cs work?  DisplayCategories() ?

Is my thinking correct ?? Reasonable to you ??  I would hate spend 2 days going down  the wrong page.

Thanks!!

Craig