Place Widget with Placement.info

Topics: Troubleshooting
Apr 12, 2011 at 9:18 PM

I have a widget that I need to place below the title of a page but before the copy and float it to the right.  I've looked in Orchard.Widgets > Drivers > WidgetPartDriver.cs for the name to refer to widgets but when I use it in the Placement.info file nothing happens; the widget still sits at the bottom of the content container. Is there something I'm not accounting for with widgets or is this not possible with widgets right now?

<Placement>
<Place Parts_Widgets_WidgetPart="Content:1" />
</Placement>

Coordinator
Apr 12, 2011 at 9:20 PM

First, you need a zone in your theme that is at the right place. Then you'll be able to go into the widget admin screen and put it there.

Apr 12, 2011 at 9:30 PM

I have it set to the Content Zone currently.  How do I split apart the text and body and inject them into the content zone as well as inserting a new zone into the content zone in order to place this widget between the title and body?

 @if (Model.Content != null) {
   <div id="content" class="group">
     @Zone(Model.Content)
   </div>
 }

 

 

Coordinator
Apr 12, 2011 at 9:34 PM

Placement is not going to affect your widget: placement is for the parts of content items, not for content items themselves, and it dispatches into local zones within where the item is being rendered.

If you go to the properties of your widget, it has a position parameter. That is what you want to change.

Apr 12, 2011 at 9:41 PM

That was the first thing I tried but the widget still remained below the text in the Content zone.  The widget's position is currently set to 0 and I'm guessing that the Body text is also set to the same position, but I wouldn't know where this is set.  Is there a way to modify the position of the text in the Content zone?

Coordinator
Apr 12, 2011 at 9:44 PM

Well, you could use placement to modify the placement of the body part, yes, but it is easier to set the position of the widget to before or to -10.

Apr 12, 2011 at 9:54 PM

Setting the position of the widget is not affecting it's placement in the zone.  I've tried before, -10  and -1000 and nothing's changing.  Know any reason why this is?

Coordinator
Apr 12, 2011 at 10:00 PM

Please file a bug on the issue tracker.

To work around this, please put it into a different zone that is directly above content. If there isn't one already, create it in your theme's layout.cshtml file.

Apr 13, 2011 at 4:50 PM

I'm not sure this is relevant here, but I had a similar issue when I was trying to add an image gallery part to my Blog page.  My image gallery kept showing up below the comments no matter what value I put in the placement.info file for the gallery.  As it turned out, I had to adjust the placement.info file for the gallery AND the placement.info file for the comments.  I don't have it in front of me, but I think I did something like 

Image Gallery:

 content:after

Comments:

 content:2