Shapes not found in Folder Items, in Version 8

Topics: Writing modules, Writing themes
Sep 14, 2014 at 5:17 AM
Hi, i am developing in localhost using Version7, and for some reason i had to install on the server the version 8. The thing is that i have too much shapes, so i am using an item folder, orchard can find that shapes in version7, but in version8 it can't.

Maybe it is a new feature..

does anybody here knows about this?

Sep 14, 2014 at 5:47 PM
Sorry but I can't understand what you are talking about. By "version 7/8" you mean Orchard 1.7 and 1.8? What is this "item folder"? What do you mean you have "too much shapes"?
Sep 14, 2014 at 10:24 PM
sorry, i wrote it very fast without think it well!!

In my theme there is a folder called Views. Here is where is suposed to put all the cshtml files.. But sometimes you have too much cshtml files, so you need a way to organize it.. Orchard lets you put the cshtml in other folders like: items, parts.. and i have seen in orchard framwork where is the class where it can be arranged.. The thing is that in my project it works fine using the items folder, i mean, puting views in there. But when i deploy it, it does not work.. it only works the view folder, and i am deploying in a server with ORchard1.8
Sep 15, 2014 at 12:34 AM
For shape templates only those special folders can be used, and a standard shape can only be in the root of Views. Other view templates will work as normally in MVC.
Sep 17, 2014 at 5:39 PM
Sorry, i am confusing about the dif btwn template shapes and standard shapes..

I have this structure:
In Layout.cshtml there is a line like this:
@Display( New.Comments() )

It works fine in my localhost project, using Orchard1.7.2!!

When i deploy it to my webserver using Orchard1.8.1 It throws error 500. Off course it was the shape not found.
Ok the solution is to put all the cshtml in views... But it becomes annoying when you have more than 30 cshtml files..
Sep 17, 2014 at 5:49 PM
Out of lazyness I used "shape" where I should have "shape template", sorry for the confusion. Shapes are a different story, what you care about now are shape templates (i.e. template files for rendering shapes) and "normal" templates (I don't know whether we have a terminology for this) like ones you have in standard ASP.NET MVC.

New.Comments() will create a shape object (see the above link), then Display() in the end will cause it to be bound to a template somewhere. I think how this "binding" happens can be extended somehow but by default for the Comments shape only templates in the root of Views folders (all of them) will be taken into account.

So if this is indeed working on your local then my guess would be one of these:
  • It's not actually using that shape template but you have a similar Comments.cshtml somewhere else too. Check it to make sure.
  • You actually have some logic extending the default shape binding strategy that runs locally but somehow doesn't when deployed. E.g. it's not deployed somehow, or the module is not enabled.
Sep 17, 2014 at 7:08 PM
mmm.. It could be.. it is a common error in programming, to be calling things that are not supposed to be called.

It should be a way to extend the folders via config files... It is supposed to be changed it here..
public class BasicShapeTemplateHarvester : IShapeTemplateHarvester {

        public IEnumerable<string> SubPaths() {
            return new[] { "Views", "Views/Items", "Views/Parts", "Views/Fields" };
But i am not going to do it, in future updates i don't want to spend 2 days figuring out that the error was that manual change in framework.

I don't know if this feature can be extended in a module and write something for developers like me that want "Template Shapes" organized in Folders according to functionality.

Orchard has spent an enormous effort in designing a beauty system for rendering shapes, and i am happy about creating shapes and Template Shapes. But if i use it too much, i get this kind of issues (organisation). I think there should be an entry in themes.txt, or at least via Interface, or whatever other source, to allow the theme developers selecting template shape folders. Why can't just search subfolders in a recursive way in the BasicShapeTemplateHarvester class? Some special reason for that? or just as you mentioned before "Lazyness", xd!