This project has moved. For the latest updates, please go here.

View files for different category levels

Coordinator
Feb 3, 2010 at 9:47 PM

Is there a way currently to have different .view files for the different navigation levels?  For example, my top level categories, I want to have a page that shows their child categories, but for the child categories, I want to show the posts in the category.  I know I can specify Category.view to set all category pages to use that view and Category-Name.view to get a specific category name to use a specific view, but what I'm looking for is something like Category.Subcategory.view.

I know that I could use Category-Name.view and just duplicate the .view files for each top level category, but I'm trying to avoid doing this.  If this isn't possible currently, what are everyone's thoughts on adding this capability at one point, and what kind of rules should be put into place for it?

Coordinator
Feb 3, 2010 at 10:17 PM

Try childcategory.parent-name.view -- so if your main category is BLOG the view file would be childcategory.blog.view

I hope that helps. I've never used it before, but noticed it in the source code.

Coordinator
Feb 4, 2010 at 1:07 AM

Thanks - that's a step closer.  Unfortunately, I still need to duplicate the view for each parent, but it's a little less duplication this way.  I may take a closer look and see if there's a good way to extend it a step further.

Coordinator
Feb 4, 2010 at 1:20 AM
You can use category.view to render the main categories and childcategory.view for the sub-categories.

I guess I am not following what further is needed?

-Jeremy-
(via iPhone)



On Feb 3, 2010, at 8:07 PM, "charlesboyung" <notifications@codeplex.com> wrote:

From: charlesboyung

Thanks - that's a step closer. Unfortunately, I still need to duplicate the view for each parent, but it's a little less duplication this way. I may take a closer look and see if there's a good way to extend it a step further.

Coordinator
Feb 4, 2010 at 1:41 AM

I didn't know you could just do childcategory.view.  That does what I wanted to do.  Your original post mentioned doing childcategory.Category-Name.view, which if that was all there was support for, then I would need multiple views like that for each top level category.

Coordinator
Feb 4, 2010 at 1:54 AM
Okay, cool. Yes, both of those are supported I can confirm in the latest code. If you are running 1.2 or earlier I am not sure when it was implamented (maybe always).

-Jeremy-
(via iPhone)



On Feb 3, 2010, at 8:41 PM, "charlesboyung" <notifications@codeplex.com> wrote:

From: charlesboyung

I didn't know you could just do childcategory.view. That does what I wanted to do. Your original post mentioned doing childcategory.Category-Name.view, which if that was all there was support for, then I would need multiple views like that for each top level category.

Coordinator
Feb 5, 2010 at 4:23 PM

If I recall correctly, those expanded options for Category views were added in Graffiti 1.01 (a.k.a. Graffiti 1.0 SP1).

A category will look for a matching view file in the following order. For the examples, assume the parent category name is "ParentName" and child category's name is "ChildName"

  1. If it is a top-level category and a view file exists with the category name. Example:  ParentName.view
  2. If it is a child-level category and a view file exists with the format [parent-name].[child-name]. Example:  ParentName.ChildName.view
  3. If it is a child-level category and a view file exists with the format childcategory.[parent-name].  Example:  childcategory.ParentName.view
  4. If it is a child-level category and a view file exists with the name childcategory.view.  Example: childcategory.view
  5. If it is a child-level category and a view file exists with the parent categories name. Example:  ParentName.view
  6. If a view file exists with the name category.view.  Example: category.view
  7. If a view file exists with the name index.view.  Example: index.view

For Graffiti 2.0 when we add unlimited nested (n-level) categories, we'll need to rethink the category view naming conventions.

Feb 5, 2010 at 5:14 PM

For v2.0, what about the possibility of decoupling the category names from the view files. Perhaps adding a 'class' to a post, with whatever defaults would be required, would make more sense. So each post could have a class (or document type like umbraco), and that class/type would be tied to a view file. I think this would give more flexibility than using the category/post names alone.

For backward compatibility, perhaps if the 'class' is blank, it uses the mechanism that exists now, but if there is a class/document type assigned it becomes an override.

Just my two cents...

Coordinator
Feb 5, 2010 at 7:42 PM

Just an FYI - when I was playing around with #3, my posts that were in a child category under ParentName, and I had a view named childcategory.ParentName.view, I'm pretty sure that the post was using that view as well, instead of the post view.