This project is read-only.

Title field in a Widget.

Topics: Customizing Orchard, Writing modules
Nov 15, 2011 at 3:36 PM

Where does the title field come from when building a widget?

I know there is a way to suppress the Body part for a widget by not adding:  WithPart("BodyPart") to the migrations file. 

But I need to suppress or at least customize the title part. I can keep the title part but I need it to be an HTML TextArea. Not just a single textbox.

I know I can make my own TextArea field for my widget, but then I would need to supress the title part.




Nov 15, 2011 at 4:00 PM

The title is part of WidgetPart, so you can't exactly get rid of it, however you could suppress its display by overriding the WidgetPart template.

What exactly is your goal, a title part that contains body text is just a reflavoured BodyPart isn't it?

Nov 15, 2011 at 4:14 PM
Edited Nov 15, 2011 at 4:17 PM

It is, but a single small textbox is limiting for some one who wants to add a super long title. It's just an aesthetic thing I guess. Would like the option of a TextArea instead of text box.

I guess my goal is to ultimately have control over the styling and placement of the title part.  Or any other field I add to a custom content Type for that matter.  When I create my own custom parts I can style them right in the Views. Just not sure how to gain control over the Title part. When I publish a page They just show up as some default HTML divs. For instance, I add a datetime field to my content, what if I want it to appear in a specific Zone like Tripel Third. Not just dropped below the body of the page. And I don't want to build a custom widget for every field I need.

It could be staring me right in the face, I just don't see it.




P.S. Speaking of placement. How are the numbers in the Placement file determined? I'm having a hard time figuring out , for example:

<Place Parts_Product_Edit="Content:7.5"/>

How do I know where 7.5 is on a page?

I mean 7.5 is such a random number. 7.5 in reference to what? If 1.0 is the reference point, Where does 1.0 begin on a page?

 Is there some visual aid Orchard has to help with this?

Nov 15, 2011 at 4:27 PM

Dealing with your points separately because they touch on various concepts:

Just not sure how to gain control over the Title part.

If you want to change behaviour or styling of existing components in Admin, you'll have to create your own module. Actually, all it needs to do in this case is override the WidgetPart editor template (you can copy this from the widgets module). In other situations you might want to do more, such as write a custom driver for an existing part to completely change the behaviour.

I add a datetime field to my content, what if I want it to appear in a specific Zone like Tripel Third. 

This is harder. Content zones are not the same as Layout zones (I think I mentioned this in the Branding thread). For ContentParts, you have to write your own driver to push the shape to a layout zone. For fields, I'm not even sure - I think you could write a Content Handler that looked for a specific named field and pushed it to zone, but really for any complicated behaviour you should just create a ContentPart. I would also like a neater solution to this problem, I have some ideas but nothing exactly concrete yet.

How are the numbers in the Placement file determined?

They are relative only to each other. If one shape is at 7.5 and another is at 7 then, well, the shape at 7 will appear first before 7.5. That's all. All shapes have default positions which you can see in the of that module, or you can enable Shape Tracing and I think that tells you the position, and that is a very good visual aid.

Nov 15, 2011 at 6:17 PM

Thanks Pete!