Composite C1

Composite C1 is a free open source .NET-based web content management system. This page describes how to accomplish some tasks, especially with regard to XSLT functions and data types.


Adding an HTML editor to a datatype

How to create a field with HTML field type, how to create a datatype with editable HTML.

Change the widget type to VisualXhtmlEditor.

  1. Create a datatype and add a datafield of type "string".
  2. In the field editor, go to the tab "advanced".
  3. Click "Widget type".
  4. Delete the current widget.
  5. Add the "VisualXhtmlEditor" widget.

More about: widgets. Example: OmniCorp demo, News dataitem.

Show an image in a XSLT function

Get the URL for a C1 Image File reference in a function, display media using a data reference, create image tag to an image from data.

Add an image tag with ~/Renderers/ShowMedia.ashx?id=ID as the source.

ID is the ID of the media, which looks like a GUID. For example, if you have a data field which has the type C1 Image File and is named Media, you can add it to the HTML output like so:

<img src="~/Renderers/ShowMedia.ashx?id={@Media.Id}" />

Don't forget to add Media.Id to the selected parameter values, under the Function Calls tab.

Get the URL for a page by Id in a XSLT function

Link to the page containing the metadata object, creating a link in an XSLT function.

Link to ~/Renderers/Page.aspx.

If you want to link to a page for which you have the ID, you can insert a link like this:

<a href="/Renderers/Page.aspx?pageId={$pageId}">Hello world</a>

This link gets changed to the actual page for this pageId.

Alternative: get page from SitemapXml.

Add a call to the SitemapXml function to your XSLT function, then search for the corresponding page in the SitemapXml:

<xsl:param name="sitemap" select="/in:inputs/in:result[@name='SitemapXml']/Page" />
<xsl:variable name="url" select="$sitemap//Page[@Id=$pageId]/@URL" />
<a href="{$url}">Hello world</a>

Alternative: link to ~/page({$pageId})

From Composite C1 version 2.1.3, you can create a link like this:

<a href="~/page({$pageId})">Current Page</a>

Use a HTML field in a XSLT function

How to parse an XHTML value from a data field used in XSLT functions, use a VisualXhtmlEditor field in a XSLT function

Call the Composite.Xslt.Extensions.MarkupParser function

Add a call to the MarkupParser function on the Function Calls tab, and use the following code:

xmlns:Parser="#MarkupParserExtensions" />

More info: XSLT FAQ.

Get only the data in the current page datafolder

How to get the data for the currently active page.

Use the ActivePageReferenceFilter.

The ActivePageReferenceFilter resides in the same namespace as you data function and allows to select data by page scope. For example, you can select only the data on the current page.

More about: using active page reference filter.