Custom Layout Widgets with Placeholders
I am still trying find a way to accomplish #4 as mentioned Thread.
I don't know if the semantics are correct, but simply put, I would like to make my own layout widgets that are similar in function to the layout widgets when editing a page. You drag and drop a layout onto your page, then you can add a generic content widget inside it. This would work excellent when I want to wrap 'generic content' with unique markup.
I believe the intended results are all the same, but depending on how people on the forums frame the problem, I am reading it's both possible and impossible. (A user control with a placeholder, a widget with a layout, etc.)
Is there any way to accomplish this?
Hi Kurt,
Please check the following thread and especially the reply of my colleague Stanislav Velikov about creating custom layout controls. I believe it suits your requirement:
http://www.sitefinity.com/developer-network/forums/suggestions---/contentplaceholder-in-usercontrol
Same question here as the OP. I followed the link posted by Jen, but the other thread doesn't really answer this specific question:
How to create a custom layout widget with a placeholder that can be dragged and dropped into a page and allows to insert another Content block widget?
The problem I have with how the tutorial describes building a custom layout widget is that the code output requires the use of sf_cols and other Sitefinity specific classes. Besides, it creates redundand code like this (as generated by Thunder):
<div runat="server" class="sf_cols">
<div runat="server" class="sf_colsOut sf_2cols_1_50 CustomClass1">
<div runat="server" class="sf_colsIn sf_2cols_1in_50">
</div>
</div>
<div runat="server" class="sf_colsOut sf_2cols_2_50 CustomClass2">
<div runat="server" class="sf_colsIn sf_2cols_2in_50">
</div>
</div>
</div>
If I need a simple 1 column container, I can edit the above to make it into a 1 div container. However, it still involves using at least two div's since without a class of sf_colsIn, the placeholder associated with this layout widget doesn't display. As such, the custom layout is useless.
Secondly, I'd like to use my own custom CSS classes without any instance of Sitefinity specific classes.
And lastly, not every page construction requires layout widgets or content blocks that involves div's. I'd like to be able to create a custom layout for ex. a H1 element, or any other HTML elements. For ex:
<h1 class="customClasshere">title</h1>
That's the output I'd like to see from the CMS. No Sitefinity classes, no id's, nothing.
Is this possible?
Thanks,
Hello Kurt,
You are correct - our layout widgets cannot contain only one div tag. The classes are required in order for them to be able to contain widgets and other content. Our css classes are easily overwritten so you can just do so and apply your new style to the layout.
I admit that there is a lot of markup generated when creating a Sitefinity page, but that is by design and that enables all of the functionality our CMS offers. By design you are not able to alter html elements such as h1 and so on. If you wish to do so you can always add raw html in our content widget and it will be displayed as such.
Regarding the usefulness of the layout widgets - if you are not satisfied with them you can always create a page template and assign ContentPlaceHolders( these are not simple div tags) anywhere on the page you like. There you have controls over styles and classes as they do not use our Sitefinity classes.