How to document HTML tags within the Umbraco/TinyMCE editor environment? Options
jhildeman
Posted: Tuesday, May 06, 2008 10:14:19 PM
Rank: Enthusiast

Joined: 6/12/2007
Posts: 23
I am using Umbraco v3.0.3 and want to be able to document various html or code blocks in my bodyText content areas updated by TinyMCE. NOTE: I DON'T want this to be executing code like an object tag for flash, or an iframe calling some other site. Essentially, I want to do the equivilent of Server.HtmlEncode() on save and decode on display.

I love what this forum allows you to do with the code block button (5th button from left during post) and want to duplicate that functionality in tinyMce

How can I get Umbraco to do this?
drobar
Posted: Tuesday, May 06, 2008 11:18:56 PM

Rank: Umbracoholic

Joined: 9/8/2006
Posts: 1,256
Location: KY, USA
As with most things in umbraco, there are a couple ways to do this. Here's one way...

Create a macro that has a multiline text box parameter (let's assume the parameter's alias is 'code'). Check the "use in editor" box. This is where you'll paste your html code.

In the xslt associated with that macro, I'd have something like the following:
Code:
<div class="code">
    <xsl:value-of select="/macro/code" disable-output-escaping="yes"/>
</div>


Then you can style your div with css to put a box around it, assign a fixed-width font such as Consolas or Courier, and your output should be solved.

When you're in the rich text editor, simply click the "insert macro" button and select the macro you just made whenever you want to put some code in. Paste in your raw html. That's it.

You'll want to add line break handline (check out the umbraco.library:Replace() function) but that's the basic idea.

cheers,
doug.

MVP 2007-2009 - Official Umbraco Trainer for North America - Percipient Studios
mrshrinkray
Posted: Wednesday, May 07, 2008 8:58:20 PM

Rank: Aficionado

Joined: 8/4/2006
Posts: 101
Location: London
You'll have great difficulty doing it with Tiny MCE, even if you change its settings via the config files (as lots are hard coded into the umbraco source). What I have done is create a custom documenttype that accepts raw HTML, it sounds hacky but always works.

If you look at http://www.sloppycode.net/code-snippets.aspx#C# those are done with wysiwyg editing enabled, with a custom property for the snippet that the XSL outputs as a textarea (the template has a macro embedded at the top of it).

http://www.sloppycode.net/code-snippets/cs/xml-comment-cheat-sheet.aspx is done with raw html as the bodyText to allow 'N' textareas on a page.
jhildeman
Posted: Thursday, May 08, 2008 4:29:28 PM
Rank: Enthusiast

Joined: 6/12/2007
Posts: 23
I love what you have done on http://www.sloppycode.net/code-snippets/cs/xml-comment-cheat-sheet.aspx with text areas. Can you elaborate further on your technique? When I put "raw html as the bodyText", TinyMCE eats it up.

Also, where are you doing the styling for the text areas?
desmo
Posted: Tuesday, May 13, 2008 5:47:18 AM

Rank: Aficionado

Joined: 7/19/2006
Posts: 154
Location: NYC
@mrshrinkray: thanks for posting your idea - very cool!

@jhildeman: he's using this: http://code.google.com/p/syntaxhighlighter/
It's got the stylesheet built-in and the script does it all for you.

I believe the raw HTML goes into a property like a multi-line textbox (no wysiwyg), then you can put however many textareas, and the script style's them.

If you just want a code section at the end of your page (or once, anywhere), you could add a multi-line textbox property to a document and use XSLT to output the textarea.

- Mark

- EDIT -

I've been wanting to implement something like this, and the google code takes about 5 minutes to get going. I did a page here with the raw HTML method:

http://manhattanheavy.com/blog/2008/5/13/simple-smugmug-c-wrapper.aspx




Manhattan Heavy Industries

“Algorithms are small but beautiful”, Dr. Karp observed.
Users browsing this topic
Guest


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.