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

Question about layout.view files

Apr 11, 2011 at 11:37 AM

I started a new Graffiti project based on the recent 1.3 beta version.

I want to be able to adjust/layout each category content separately through view-files.

Therefore I have 3 view-files per category. For example for the category "cars" I have:
cars.view
cars.post.view
cars.layout.view

It works well on the category overview page, but not for each post, I publish within the category.
Graffiti still uses the normal layout.view file to render each individual post page within the categery - not the cars.layout.view file as I intend for all separate posts within this category.

I am quite sure that some years back Scott (who previously worked for Telligent on the Graffiti project) helped me with a quick-fix solution to a similar problem in an older version of Graffiti, but I simply can't find the e-mail and unfortunately all the old Graffiti CMS forum replies are not available anymore. If I remember correctly Scott just provided me with a few lines of code, that solved the problem.

Can someone here direct me in the right direction on how to ensure that all posts within a specific category uses the targeted layout.view file?

Thanks.

Apr 11, 2011 at 5:39 PM

I have an active site built on the original telligent 1.2 release using this same setup.

The trick to get it to work on mine was all about the naming conventions for the view files.  Just to ensure that this is all good...go to categories and edit the category you are playing with.  The link name is what you need to name your views after if I remember correctly.  The other little gotcha I remember was anything that had a multiple word category name for some reason you have to put in with dashes...so if you have a category named Plastic Silverware and the link name is Plastic Forks then you would have to name your file plastic-forks.post.view.

Also make sure that you have caching turned off for your testing...it was a manual edit of the web.config in 1.2...I think they now have a toggle in the admin console for it.  If you don't turn off caching...you will get very random results as to when you are shown a cached page vs a changed page.  Make sure and turn it back on when you are done.

HTH,

JH

Apr 11, 2011 at 11:44 PM

Thanks a lot for your reply, JH.

I have previously had the intended layout.view override working with both Graffiti 1.2 (by Telligent) and Graffiti 1.3 Alpha (first open source version), but with Graffiti 1.3 Beta 2 I just can't get it to work.

I am aware that the category link name must be used when naming view files (including the dashes) and I had already turned caching off for testing, so these are not the troublemakers.

I had a look at the Source Code history here in Codeplex today and I notice Change Set 52527 saying "Prevented a CategoryName.view file from overriding the default post.view file for posts in that category"

However I don't know if this change also prevents a specific category layout.view file from overriding the normal layout-view file for posts within the specific category.

As mentioned in my initial post, I believe I initially received a special code-fix advice from Telligent in the old original Graffiti Forum, which is not available anymore, and I have not been able to locate posts describing similar issues.

The reason why I want different layout.view files is that my general layout.view file has a 2-column layout whereas my specific layout.view files have a 3-column layout which is also used for posts within the specific category.

Thanks for any further advice on how to get the override layout.view functionality to work.

Coordinator
Apr 12, 2011 at 12:04 AM
Edited Apr 12, 2011 at 12:06 AM

I did some tests on my own site with beta 2.

Heres how category-name.layout.view takes effect:

category: correctly uses category-name.layout.view
category-post: incorrectly uses default layout.view instead
category-category: correctly uses category-name.layout.view
category-category-post: correctly uses category-name.layout.view

must be a bug? to work around, you could create category-name.post.layout.view which contains nothing but $macros.LoadThemeView("category-name.layout.view") to force this view to load instead. Therefore you get this result:

category: uses category-name.layout.view
category-post: uses new category-name.post.layout.view pointing to category-name.layout.view
category-category: uses category-name.layout.view
cateogory-category-post: uses new category-name.post.layout.view pointing to category-name.layout.view

Note how this work around affects the subcategory's posts as well.

Can someone confirm this is a bug and that I'm not missing something? It makes no sense to allow this view to affect the child category's posts but not the parent category's posts...