Ticket (Solved)

What to use 'Widgets' or Layouts etc.?

Hi All, I’ve been erring on the decision of whether or not to use Orchard on a project as I’m struggling to separate what can and can’t be done, and more importantly, with what? Looking up tutorials and documentation, I’m not sure if I’m really dense, or if there is a lot of misinformation/deprecated literature; my main point of confusion is with widgets and layouts / elements / blueprints / templates etc., and when to use what type? So, I thought I’d propose a simple situation and have you helpful folk tell me if I’m on the right track ;) I’ll have six pages of content, which I assume will be straight forward to implement, though I wish to reuse all those six pages content into one page [let’s ignore SEO for now] – and using that pages name/type as a conditional marker – reduce the amount of content [some elements like image sliders etc.] that is displayed for each section; basically, becoming a synopsis of each. Am I right in assuming Layouts is the key for this scenario, along with ‘I think’, Element Rules? My concern is what to use [as some old widget literature seemed to fit the bill as well]. So assuming Layouts is what I’m after, what should I use as these reusable containers [ignoring the overall sites template which I believe I can create/override via document/Layout.cshtml] – the six pages will have some common wrappers etc. [so some sort of template], but the content will need to be altered for each by the user – so then some way to make the template editable on each page’s layout as well as reusable/automatically updating on other pages [namely the synopsis page] that use this 'element'? Is this possible and can anyone clear up my understanding/terminology if needed. Thank you very much for your time, PP

Re: What to use 'Widgets' or Layouts etc.?

If I understand correctly, you basically have 6 content items of some type (probably Page, but could be any type of content), each of them having their own URL. At the same time, you have a single page that displays these pages as the synopsis of each. If so, then this is what I would do:

  1. Create the 6 individual pages.
  2. Create a Projection Page with a Query that selects the 6 pages.
  3. Use your theme to provide markup for the "Summary" (or a custom display type) view of the content items. Alternatively, take over the rendering of the projection page entirely by providing the Shape layout for the Query used by the projection and handle all the rendering of each content item yourself. Whatever you choose, you will be able to provide common wrapper HTML for each rendered item.

I'll try to clarify the deal with Layouts and Widgets next:

The Layouts module provides a canvas onto which you can add elements, and are essentially a way to layout your content. Like BodyPart, it's a way for to user to provide content. The key difference is that the user can visually design layouts of this content using elements such as Grid, Row, Column and Html. It also comes with a Projection element which you could add to your page to render a predefined query, so instead of creating a Projection Page as described in step 2, you could create a Page and just add a Projection element to it. This gives you the ability to easily add more elements to your page.

Use Widgets when you want to add content to Zones as rendered by your Layout view. They are great when you have a piece of content that you want to show on multiple pages because they are bound to layers, not content items. However, if you have page-specific content that only appears on a single page, you should consider adding elements to your page instead. Unless that content needs to be added to a Zone.

If you're not sure how to draw the line between using layouts/elements and widgets/zones, just think of the LayoutsPart as if it were the BodyPart. Its scope is local to the content item and just a fancy way of laying out content (instead of using the HTML view of TinyMC to add tables for columns of contents, you now have a visual designer to create columns of contents). LayoutsPart has nothing to do with Layout.cshtml and its Zones.

I hope this clarifies a bit, but please let me know if you need further clarification.

Tuesday, December 1, 2015 2:34:47 PM bysfmskywalker

Re: What to use 'Widgets' or Layouts etc.?

Thanks sfmskywalker, that has helped tremendously -- and sorry for the belated response as I've been on leave. Although, I'm a bit confused with the "projection element", I can’t find it anywhere so I assumed it's a feature after 1.9.2. Therefore, I noted a post about acquiring 1.9.x from github, but upon inspection, I also saw 1.9.3 which also includes "Orchard.Layouts.Projections"; so, which should I develop from (as in, what's recommended and more stable)? Thanks for the very informative post and all your help. PP

Monday, January 18, 2016 3:20:39 AM bypigpen
  • pigpen
  • Lv. 02 Rookie
  • Total EXP: 58

Re: What to use 'Widgets' or Layouts etc.?

Oh dear - brain still on leave...I used the module search with 'layout' and couldn't find it as I new the feature was Orchard.Layouts.Projections; but of course, it's called 'Projection Element' sorry. I'll try and tackle what you suggested now, thanks PP

Monday, January 18, 2016 5:03:09 AM bypigpen
  • pigpen
  • Lv. 02 Rookie
  • Total EXP: 58

Re: What to use 'Widgets' or Layouts etc.?

Ok, so I've sorted out most of what you proposed, but have some related questions - but slightly off-topic for this one. So I will post a new ticket once I get my head around what I can't achieve. Thanks for all your support, PP

Monday, January 18, 2016 7:08:20 AM bypigpen
  • pigpen
  • Lv. 02 Rookie
  • Total EXP: 58

Post a reply

You need to be signed in to post a reply.

Sign In