Need help realising this setup

Topics: Administration, Customizing Orchard, General, Troubleshooting, Writing modules, Writing themes
Feb 26, 2014 at 8:58 AM
Edited Mar 11, 2014 at 10:35 AM
Hi,

I'm currently implementing our redesigned website in Orchard, and I need some help or pointers on how to set some things up. First let me explain what I have so far.
In our design, we have several "Quotes" per page that need to rotate every x seconds. Every quote has two "lines", line1 should be displayed in the BeforeContent zone, and line2 should be displayed in the AfterContent zone. So I've created parts, partrecords, drivers and handlers for these objects:
QuoteGroup
  Name

Quote
  Group
  Line1
  Line2
This works and I can create QuoteGroups and Quotes and they are stored in the database.

Problem 1:
What I would like to do now is to modify the Page content type so I would have to select a QuoteGroup from a list of existing QuoteGroups already created. I'm not sure how to do this. I tried adding the QuoteGroup content part to the page content type but then it renders the QuoteGroup editor template when I create or edit a page. I guess I should somehow show a different editortemplate?

Problem 2:
When the above has been realized, I would like to render the Quotes in my page. I think the best place to do this is in my custom theme? Using the .As<QuoteGroupPart>() extensions method? This is a guess as I can't try it at the moment because I'm stuck on problem 1.

Any help is greatly appreciated
Mar 11, 2014 at 10:35 AM
Edited Mar 11, 2014 at 1:38 PM
Any help on this please? I'm still stuck on problem 1.
Edit: I just thought of something: perhaps I should make a "QuoteField"? Which I can then add to the Page content type?
Developer
Mar 12, 2014 at 8:15 PM
It looks like you'd want to develop a widget that you then can place into arbitrary zones on the layout. Check out the docs on how to create a widget.
Mar 13, 2014 at 10:33 AM
I know how to make a widget, that is not the issue. My main problem is this:
Problem 1:
 What I would like to do now is to modify the Page content type so I would have to select a QuoteGroup from a list of existing QuoteGroups already created. I'm not sure how to do this. I tried adding the QuoteGroup content part to the page content type but then it renders the QuoteGroup editor template when I create or edit a page. I guess I should somehow show a different editortemplate?
Developer
Mar 13, 2014 at 12:56 PM
That's why I told you about widgets, because it looks what you really need is widgets. Because when you attach a content part to a content type then it will have that part's editor in the items' editors. You can use editor groups (this is what the only Site content item does, to have multiple subpages of settings) but to use them with Pages you have to write code for showing the editor.
Mar 18, 2014 at 12:08 PM
Edited Mar 18, 2014 at 12:12 PM
I'm not sure what you mean by editor groups? Do you have a link or something to point me in the right direction?
Just to make sure I've added some pictures to further explain what I mean (in a bit of a simplified scenario).

I've created a "Quote" content type that is creatable so I can make new quotes from the dashboard menu:
Image
When you click it you get it's editor template:
Image
I've added the quote part to the page content type:
Image
Now when I create or edit a page, I get the same editor template:
Image
This is not what I want, I want to display a dropdownlist or something to be able to select already existing quotes
Mar 18, 2014 at 12:15 PM
May be you should make a Quote ContentItem and use a List of it inside page with an alternate to display a dropdown
Developer
Mar 19, 2014 at 1:23 AM
One sample of using editor groups is in Combinator (metadata in handler, grouping in driver). But to use groups you'd need to construct the editor from code.

But with your illustration it's clear that you need some content item composition. So you could do what CSADNT suggests: have a separate content type, then add items from that to your Page items. Such content item composition can be achieved with the Content Picker Field, Container and Containable Part and also by using Projector queries and displaying them with ProjectionPart.