简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM