C# return datatype field data from VisualEditor as unencoded

Topics: General, Troubleshooting
Apr 6, 2011 at 6:07 PM

Hi everyone,

Late adopter of C1 (and just "wow" at the system) and need a little help.

  • I have written a c# class containing function returning IQueryable<T> but I can't get my head around how I put html content into the page instead of it display the tags i.e. bold text  instead of <b>bold text</b> based on a DataType property field i.e. Icst.TeamMember.HtmlDescriptionField <- I want that to be displayed as per the WYSIWYG content added by the user

Thats the major one

Minor questions:

  • Where do Visual function code (be it xslt or w/e) go when created? Or is it some form of magic sugar happening in the .dll?
  • Where can I find the xslt function API reference?
  • A general high level architectural overview of the pipeline might be nice.

Apart from that though I have to say C1 is something very special... Thanks team

Coordinator
Apr 6, 2011 at 6:43 PM
Edited Apr 6, 2011 at 6:49 PM

tnx for the wow - don't be to shy to review us - it helps spread the word ;-)

If you have a data field with xhtml in it, and you emit it from a C1 Function - like a C# Function returning XhtmlDocument or an XSLT function - you need to emit the xhtml "as DOM" and not as a string. If you treat it like a normal string automatic xml string encoding will occur.

In an XSLT Function you would change <xsl:value-of select="@HtmlDescriptionField" /> to <xsl:value-of select="Parser:ParseWellformedDocumentMarkup(@HtmlDescriptionField)" xmlns:Parser="#MarkupParserExtensions" /> and ensure that 'Function calls' has a call to the Composite.Xslt.Extensions.MarkupParser function.

In a C# scenario returning XhtmlDocument, XElement etc. you would change code like myXelement.Add( teamMember.HtmlDescriptionField ) to myXelement.Add( XElement.Parse(teamMember.HtmlDescriptionField) ).

In ASP.NET Web Forms and MVC scenarios you just print the value raw as you normally would.

Seems we don't have this on docs.composite.net yet - a pretty obvious use case we should cover... we will fix.

> Where do Visual function code (be it xslt or w/e) go when created? Or is it some form of magic sugar happening in the .dll?

They are handled by their respective "Function Providers" - if you browse the source code, look under Composite.Plugins.Functions.FunctionProviders. XSLT functions compile the XSLT source once and then invoke it with input/function results on render, visual function is doing some fancy 'dynamic expression tree buildup, compile and invoke' at first runtime etc. (as far as I remember).

> Where can I find the xslt function API reference?

In the Functions perspective, open All Functions, Composite.Xslt.Extensions, and use "Generate Documentation" on the folder. This contain Xslt extensions you can get by including the function call on your XSLT. The individual XSLT extension will then 'document itself' in your xslt preview once it is included. Also see http://docs.composite.net/C1/XSLT/GuideToXsltFunctions.aspx/Editing-the-Template.

> A general high level architectural overview of the pipeline might be nice.

We don't have it documented at the moment - but try adding ?c1mode=perf to a page rendering (require 2.1) and you will see a call tree. This may give you some indication of the page rendering process.

Apr 6, 2011 at 7:41 PM

That's the ticket... XElement.Parse ;) I would put that as a note on the C# Data tutorial

I am about to convert my team to using C1 for the majority of our web output and am about to start heavily plugging where I can to aid the cause.

Once again well done. I've waited a long time for a decent CMS package and C1 has just destroyed the competition to be honest... Drupal and Joomla beware also...

Anyway... Thanks for help Mawtex

Apr 6, 2011 at 10:09 PM

Just a quickie sorry to take up your time marcus,

I noted the search function is limited but guess this is a predicate based filter engine? I havent really delved in the search and filtering but guess I can stack predicates and exclude results from the chain?

Thanks

Paul