user1209945
user1209945

Reputation: 81

Umbraco Editable Content Block

I am new to Umbraco and looking to add a static content block to my website that my client can edit with a WYSIWYG. I come from a Joomla/Wordpress background where this could be accomplished with a HTML Module (Joomla) or Widget(Wordpress). Does anyone know how to set something like this up in Umbraco?

Upvotes: 0

Views: 535

Answers (1)

Martijn van der Put
Martijn van der Put

Reputation: 4082

This is possible, I have created similar blocks in the past with XSLT, but of course it can be done with WebControls or MVC as well.

First, on the DocumentTypes where you want to display the static content block, add a new field called StaticBlocks. The type could be a multilist or dropdown or so, whatever you prefer as long as you can choose at least one (ContentBlock) item from the content-tree.

You need to create a new Document type, call it ContentBLock and add a RichText field to it. This is your static content block.

Also create a template for this ContentBlock and make sure the template is rendered somewhere in your main layout. This template only contains a Macro (in my case it was an XSLT macro). The XSLT Macro reads the selected nodeID from the StaticBlocks field from your currentPage, get the node by using the <xsl:variable name="node" select="umbraco.library:GetXmlNodeById($nodeID)" /> method (this is the ContentBLock). Output the value of the Richt Text Field from your ContentBlock.

That should do the trick. You can extend this by selecting random blocks from a pre-selected list or rotate blocks between page refresh, etcetera.

Upvotes: 1

Related Questions