show different content type in one page

Topics: Customizing Orchard
Nov 2, 2011 at 2:24 AM

hi:

I want to show two list of contents from different content type in one page, does anybody know how to do that?

Nov 3, 2011 at 2:19 PM

no one interested?

only solution I got in mind is: add a page, make it's content and title hidden, or looks like not so important. and add this two list to this page's layer via widget.

i don't like this way, so tricky, anybody got an better idea?

Nov 3, 2011 at 4:27 PM

You can do this with Container/Containable parts I think.

If that's not flexible enough, my Science Project modules do this in a more advanced way ( http://scienceproject.codeplex.com ) - you can create relationships between content and then control the DisplayType however you want when child content is rendered.

Coordinator
Nov 3, 2011 at 5:40 PM

PEte is right, the List content type is done for that. It's a bucket, you put what you want in it.

You could also use the Taxonomy module, by categorizing the items you want.

Nov 3, 2011 at 6:24 PM

Those sound like overkill to me, what about returning multiple shapes from your driver?

Let's say for example one of your content types parts contains something that "unifies" it with related items, be it a number or string or something. (the science project connectors do this with Ids if I am not mistaken)

Now at this point would be the time to decide if you want to use a LazyField(s) to actually bolt the related items onto the part or use an injected ContentManager to fetch them in your driver, if your using LazyFields there is lots of guidance in these discussion groups on how to do that and I would refer you to them as I think we want to get to the guts of your question, if you decide to just fetch them with the ContentManager that is done the same way you fetch content with it anywhere else.

In any event in your driver instead of returning a ContentShape using the method use the method Combined. i.e:

Combined(
     ContentShape(
          "Parts_Shape_One",
          () => shapeHelper.Parts_Shape_One( Prop: Value )
     ),
     ContentShape(
          "Parts_Shape_Two",
          () => shapeHelper.Parts_Shape_Two( Prop: Value )
     )
)

You can return any number of shapes this way. Then you simple "place" both shapes and have views for them. Viola! 2 shapes, 1 page.

 

Coordinator
Nov 3, 2011 at 6:26 PM

"Overkill" ?

That's how your suggestion sounds to me actually ;) And I think dragon753 just wants to reuse content types, not creating new ones by code.

Nov 3, 2011 at 6:38 PM

Well if no code is the requirement;  then the Container or a version there of IS really the best thing. I'd be curious to know what the specifics of the scenario are.

It just sounds like overkill to me to create something new if the 2 things are already related somehow. Different strokes.... :)

Nov 3, 2011 at 7:42 PM

I just realised I initially misunderstood the OP; what he actually wants is to display *two lists* of content (of different content types, I think). Science Project / Mechanics is already set up to be able to do this (possibly Taxonomies as well?)

Nov 4, 2011 at 4:57 AM

Thanks, you guys. that really help. I should have searched deeper.

btw, my scenario is: show some list like news list, product list, etc.  rather than one post(or some other content type) only (may be along with some widgets in side bar or footer).

so I think reverand's way is better.

and I will pay some attention to pete's project which sounds very useful.

again, thank you all.

Nov 4, 2011 at 8:49 AM

With reverand's way you have to write code ... with Sebastien's or mine you don't ... your choice ;)