This project is read-only.

Crazy plan - is there a way to render a "page (shape?)" and insert it into the output of the currently executing page?

Topics: General
Aug 21, 2014 at 11:38 PM
Hi Guys,

Okay so I'm very new to Orchard but I have a depressingly long (ie: I'm getting old) experience with .net.

Yes my plan might be crazy, but here me out. I'm trying to create what I'm hoping will be a pretty unique (design and layout wise at least) website with Orchard. Effectively it is a sort of Single Page Application approach driven by javascript. The premise I'm trying to create is a visually impressive site, but that can still be driven by a content management system.

As a point of reference, a similar design I'm aiming for comes from this demo

Working with that demo as a reference - not the finished idea but demonstrates the point - you have navigation driven as a set of simple pieces of content, a full screen image and some title information.

I can/have created a custom content type with fields for the image and title. All good so far. Now if I wanted to stick exactly to that demo, I could include an HTML field (for the content below each screen) and I'm done, but that's a little boring. I want to be able to include all sorts of content in the 'sub-page' (the content below each screen). In Orchard, if I could create a content type with Zones, I could add more widgets and other items to these zones and that's be the solution. I see from the feature roadmap that 'zones in pages' is coming, but October is too long for me to wait. I also saw the Science Project and Mechanics features which apparently lets you link content items, which seems that it would be at least part of the way, but the project appears to be dead.

My next idea is to see if there's a way I can render widgets, and other content directly. Even if the editing becomes a slightly painful process of including tokenised strings or something else similar, as long as the end result is that I can render other pieces of orchard's functionality in my 'sub-pages', I can work around the editing (or even develop a custom UI if necessary).

I did realise one plan would be to create lots of zones in my theme (zone sub-page 1, zone sub-page 2....), but the problem with that is it's static, so I would be limited to the definition in my theme.

I did see briefly elsewhere in the forum, something about Shape.Execute, which I still need to research.

So is there any clever ideas anyone has? Some secret underlying method that would allow me to use Orchard to generate the HTML and then insert it into the layout where I need it?


P.S. Now don't get me wrong, I think Orchard is pretty amazing, and I've read a few of these types of threads already (I especially like the pretty douchey guy with the ferrari and the beautiful wife/kids - like I give a crap, anyway I digress), but the docs really need some work. I know you know this, so I don't want to just moan and complain and ignore the thousands of man hours you put into this awesome platform. What I do want to do is three things:
1) I suggest a system to force documentation - it has to happen at some point guys and I know you have focused on the features, but the most painful thing to see will be a technically stunning CMS that dies a slow and painful death of non-adoption because people are struggling to get into it. So why not just force the issue - draw straws, once a week, once a month, once a sprint, however you want, and just pick a person who has to spend that length of time documenting... painful I know, but my experience of dev teams is if you don't force it, it won't happen.
2) I will put my money where my mouth is, I will happily promise a real and significant contribution to the documentation, blog article index, drawing architecture diagrams, whatever the priority is. But herein lies the rub, I didn't write orchard so I'm gonna need answers to write stuff. I'm pretty sure there are a number of people who would want to contribute to that side of things but everyone would feel like they're gonna piss you guys off sending ten questions a day, so how could you manage it? (yes the forums are one answer, but it's a pretty slow process, especially if there's time difference).
and 3) create a Uservoice or some other list to prioritise documentation work. That would also help anyone who would like to contribute to just get an idea where to start.

P.P.S. Please please don't hate me for the comment above, I know you've heard it over and over again, but there's a reason for that. It's painful to get into this system beyond the UI, and the fact is your killer feature will probably not be written by the core devs, but by someone who sees what you've built and goes 'holy shit - i could build this thing that no one's ever done before with that platform'
Aug 22, 2014 at 2:40 AM
You most definitely can. To turn a content item into a shape, use IContentManager.BuildDisplay. It takes a content item as its input, and returns a shape as its output.
If you return this shape from an action method using a ShapeResult instance, your javascript gets back the HTML.
If you want to render a shape to a string server side, simply use IShapeDisplay.

Thank you for your feedback on the documentation. We are very much aware of it. We will never hate anyone for letting us know what we need to do to improve, on the contrary, we would love you for it. We'll get to it eventually. Or maybe you. The docs, after all, are open source too. Which reminds me there was a pull request someone asked me to look at. :)
Aug 22, 2014 at 7:59 AM
This guy hits the point spot-on!

I would also like to contribute A LOT, I find Orchard amazing and really love the architecture. I started 3 months ago spending a lot of my spare time to learn Orchard, and never gave up. The more I dig, the more I see how beautiful Orchard really is.

I understand the pain for orchard-explorers, I've had it too. Luckily, I'm an awesome programmer with superious programming skills (I like to think that, don't rip me out of that dream :) ) which lead me to the understanding of Orchard I now have.

Currently with my relatively average knowledge of Orchard, I'm trying to contribute by answering orchard-related questions on SO and this forum. I would like to have more people to share my love for this platform and let it be widely adopted (which I'm sure it will, and you will be one of them!)

What really helped me was asking real-time questions on JabbR, where a few die-hard Orcharders rest, dying to answer some questions.

Luckily there are also the great orchard masterminds who explore this forum daily, helping us to find the true understanding of Orchard.

Kudo's to all of them.
Aug 26, 2014 at 8:17 AM
So I tried out BuildDisplay, but the result is just the content item, no widgets or layout, which is kinda what I expected.

With some more digging, I realised effectively what I want to render is Model.Body as you would find it in the document template. I can't work out though how it's built and if there would be a way to build it without a full page request. I ended up in LayoutAwareViewEngine, and I'm pretty sure that's too far down. Any more ideas?

With regards to docs etc, thanks sanderg. I knew there would be people who feel the same. I've put together a uservoice for documentation at I'm starting on making some real contributions like I said I would. And you're right, the JabbR channel is the place to get this stuff so expect to see me logged in there way too often.

Hopefully I'll get some docs contributions out in a few days - still got to get this website done though :D

And I second that - kudo's to every single person who's already contributed to Orchard, however big or small. It's the only way FOSS works, and it's great to see it when it does.