This project is read-only.

Assigning content part to zone

Topics: General, Localization, Troubleshooting, Writing modules, Writing themes
May 3, 2011 at 9:28 AM
I had a look at :

which made my driver Display method look like:

protected override DriverResult Display(
SlidesPart part, string displayType, dynamic shapeHelper)
//return ContentShape("Parts_Slides",
// () => shapeHelper.Parts_Slides(
// Title: part.Title
// ));

var shape = shapeHelper.Parts_Slides(
Title: part.Title

.Add(shape, 1);
return new DriverResult();

a zone is created in my layout page:

<div id="content">

<div id="leftcol"><!--left column-->

@if (Model.AfterContent != null) {
<div class="panelmain-holder">
</div><!--left column-->

<div id="rightcol"><!--right column-->
@if (Model.AfterMain != null) {
<div class="right-panel">
</div><!--right column-->

my web page looks like:
<div id="rightcol"><!--right column-->
<div class="zone zone-slides"></div>

but nothing inside the slide zone is rendered. Did i miss anything in the driver code...?

May 3, 2011 at 8:35 PM

What do your template and placement look like?

May 4, 2011 at 12:21 PM

My placement file looks like:
    <Place Parts_Slides_Edit="Content:1"/>
    <Place Parts_Slides="Slides:1"/>
Im not sure what you mean by template though...

I havn't updated my orchard to 1.1 (im on 1.0)

Could this be creating the issue?

May 4, 2011 at 6:19 PM

Well, you must have a Views\Parts\Slides.cshtml file in your module, right? That's the template for your Slides shape.

May 9, 2011 at 9:20 AM

Ah yes sorry, My template is:


@Html.Action("SlideViewer", "Slide", new { area = "Mod.Web.Slides", settings = Model.Settings.GetModel<Mod.Web.Slides.Settings.SlidesSettingsHooks>() })

it basically just calls a partial view in the Slide Controller in the module.

May 9, 2011 at 11:56 AM

I'm not sure if this is the problem, but position parameter should be a string (I think) so:

.Add(shape, "1");

Otherwise, what's probably happening is an exception in your driver. One thing to note, if you're adding shapes directly into layout then your placement file is irrelevant (it's normally handled from DriverResult which in this case you're skipping).

Best thing is to debug step thru your driver then a) see if it's even running and b) see if anything is firing an error.

May 18, 2011 at 10:35 AM

It worked!!

Thanks pete, not sure if it was changing that 1 into a string or trying this method on the 1.1.3 version of Orchard but I can now assign content parts to zones :-D