A few widget improvements

Topics: Controls
Jan 13, 2010 at 12:27 AM
Edited Jan 13, 2010 at 12:28 AM

I really like the ability to use multiple widget zones, it's a great feature that offers a lot of flexibility WRT theming. There is one drawback which is BE makes some assumptions and places hardcoded markup in the TextBox widget which is not desired.

I'd like to see two minor changes along these lines which I think would help improve the usability. First, WidgetBase.cs has an assumption that if the title of the widget is not displayed a <br/> gets inserted which IMO is not desired. Second, the tinyMCE editor used by the TextBox widget wraps all content in <p> tags which is also not desired IMO. I like to use the TextBox widget to place any markup on my theme including <script> only markup.

Therefore in WidgetBase.cs I'd like to see the following change:

if (ShowTitle)
sb.Append("<h4>" + Title + "</h4>");
else
sb.Append("<br />");

To:
if (ShowTitle)
sb.Append("<h4>" + Title + "</h4>");
And in Widgets\TextBox\edit.ascx add the option for TinyMCE for 
forced_root_block: false,
Thoughts?
Coordinator
Jan 13, 2010 at 2:51 AM

Here is an idea: while devs sitting on their hands waiting for 1.6 shipped (don't ask...) - why don't we gather here all the little, non-code-breaking changes that will improve theme creation and SEO just as widget headings you mentioned and push them in the code base? I'm sure it won't take a long time and chances are good that it will make it in the 1.6 just in time for the final cut. I'm volunteer to make changes and I'm sure Ben will help me out as well.

 

Coordinator
Jan 13, 2010 at 6:04 AM

I think it would be more ideal to create a new widget that does what you're looking for -- rather than modify the TextBox widget.  Others have asked to be able to output Google AdSense code or other pieces of Raw HTML into widgets.  It never works very well with the TextBox widget.

A new, very simple widget could be created that has a multi-line textbox in it (not tinyMce), and raw HTML would be pasted into the textbox.  I know this widget would be perfect for the AdSense and other Ad people, and sounds like it might fit what you're looking for too.

I haven't used the forced_root_block option before, but this option might not work well for people who are using the TextBox widget for more "regular" straight forward text editing.  Having <p> tags or <div> tags or other block level wrapping for content probably is what more people need, rather than don't need.

Also, if we made the first change you propose (removing the <br />), this will essentially change the rendering of text for people who are already using the TextBox widget with Show Title turned off.  This isn't a big problem, but we probably don't want to make a change that will impact a lot of blog layouts for one request (absolutely no offense intended).  I just think it makes more sense for a person to make a small tweak like this with their own installation.  This is one big advantage of BE.NET being an open source platform.

P.S.  The name of the new widget I mentioned with the multi-line textbox can be called the "Literal Widget" since it simply outputs its content literally.

Jan 13, 2010 at 7:35 PM
Edited Jan 13, 2010 at 7:39 PM

Find the Literal Widget here

I just created the Literal Widget, named "Literal" to fit in. If anyone likes it, please include it in next release...or just use it at will.

Thanks for the suggestion.  I feel a little stupid that I didn't just do this a while ago since I knew I needed it.

Coordinator
Jan 14, 2010 at 3:04 AM

That's great BizTron, thanks for spending the time to do that!

I've been a bit tight on time, but often think of the value the Literal widget has for simple things like this.  Now we finally have it!  :)

Jan 14, 2010 at 5:04 AM

Ben,
  Thanks for the reply. While I hear you on the reasons for not changing the existing TextBox widget I've made the changes indicated above and I'm now using the widget for insertion of script only blocks and it works great. I believe these simple changes make this widget a lot more functional and leave the formatting where it should be, in the hands of the theme designer. A separate widget really isn't necessary and it really wouldn't do anything different. Having this one widget with the flexibility to do either certainly seems like the right way to go IMO.

That said, I do understand that changing this widget _may_ impact a number of themes but since there aren't many themes shipped with BE and these are actually improvements that could be documented, and the changes necessary to add an extra <br /> for people who want it are really minor.

BizTron,
  Thanks for the widget!

Jan 14, 2010 at 8:58 PM

I'm glad I could help.

It looks as if an "upgraded" TextBox widget is a good idea so that anyone can use either, but moving forward, I agree that it's difficult to change what has already been decided upon for various reasons.  I would suggest a vote to "correct" things that some of us would like to see, but only after we take the time to provide a solution and make sure it is really what we want, as was done here.

Another thought is to have more idea sharing about design, architecture, etc. in advance so the community can help surface issues, wants, needs early in the process.  I have a few ideas and have implemented many on my own because I have no idea how to share...such as a working multi-blog deployment (with thanks to Proffitt for SqlBlogProvider).

Dec 28, 2010 at 5:18 AM

You wouldn't by any chance have updated this for v2.0 would you? I'm attempting an upgrade and simply copying the Literal widget into the new blog doesn't seem to be working. When I attempt to add a new Literal section nothing happens and I'm assuming there's an error that needs debugging. Unfortunately, I've recently moved to development on a Mac and don't have VS.NET installed at present making things rather difficult to debug.

Thanks in advance.
-Steve 

Coordinator
Dec 28, 2010 at 6:25 AM

There's only one or two small changes needed to make the Literal widget work in BE 2.0.

See this post.  Adding the "using" statement to the top of widget.ascx.cs, and maybe also edit.ascx.cs -- if it exists.

This change can be done with a text editor ... VS isn't needed.

Dec 28, 2010 at 6:29 AM

Thanks much Ben! Adding that using was it.