Multiple Content blocks
Hi Telerik Sitefinity,
This is Sravan from India,
My question looks to be strange and funny, But what to do do requirement is like that,
we have been developing a website using sitefinity 4.1, and we are almost at the end of project,
Mean while My client reviewed the process, and express that If you can provide some content blocks apart from the default one with specific style sheet tagged with that, that will make my job more easy, So that i can drop the control wherver i need and i want in later stages, so that total webpage can be controlled from admin end,
So here is my question, Is it possible to develop a control with content block that we can place them in a ny placeholder and after that they can enter content and assign stylesheet according to that, and it will render content html encoded in the front end as the general editor is doing ,
Note* The default content block should be there itself,
Like that i want to create multiple user defined content blocks,
Its a bit very importent, can anybody have idea please suggest me,
Thankyou, it would be more helpful for me if anybody have idea/solution
awaiting reply
regards
Sravan
Hi Sravan Kumar,
Can you please clarify what you mean by "with specific style sheet tagged with that [content block]", so we can give you a more specific advice?
Are the styles from this stylesheet going to be applied to the text in the content block? If so, the easiest way to achieve this would be to modify the Content editor's ToolsFiles and add a reference to an external CSS file that contains your styles. Then you can substitute the default ToolsFile we're using with your custom one, and this will ensure that the ApplyCSS dropdown is populated with your custom CSS. You can check this forum thread which contains a detailed discussion on achieving similar functionality, and check out the videos and code samples we've provided there.
If the functionality you require differs from the one described above, and your use case scenario is such that you need to have different content block widgets, let me elaborate a little bit on what's necessary to be done.
The base class ContentBlock implements a ControlDesigner interface of type ContentBlockDesigner. In that designer you have the a control of type HtmlField, which is the content editor control itself. The HtmlField uses RadEditor which allows us to set different ToolsFiles for each instance of the control. We've gone a step further in extending this functionality, by allowing the HtmlField to load custom EditorToolsConfigurations that can be created through Administration->Settings->Advanced->Appearance and are retrieved from the AppearanceConfig.config configuration file.
In order to achieve the desired functionality, you can create several different EditorToolsConfigurations, and in your ToolsFiles define the specific CSS that will be included in the ParagraphStyles and ApplyCSS dropdowns by default. For more information on how to customize the ParagraphStyles please take a look at this article from our RadEditor documentation, and for ApplyCSS - this one.
You'll also need the default ToolsFile which we're using, I'm attaching it to the current response.
Once you have your custom ToolsFiles for each ContentBlock added as custom configurations in the AppearanceConfig, you can then create a new custom control by inheriting from the ContentBlock class, like this:
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Web;
using
Telerik.Sitefinity.Modules.GenericContent.Web.UI;
using
Telerik.Sitefinity.Web.UI.ControlDesign;
namespace
SitefinityWebApp.Controls
[ControlDesigner(
typeof
(ContentBlockDesignerA))]
public
class
ContentBlockA:ContentBlock
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Web;
using
Telerik.Sitefinity.Modules.GenericContent.Web.UI;
using
System.Web.UI;
namespace
SitefinityWebApp.Controls
public
class
ContentBlockDesignerA : ContentBlockDesigner
protected
override
void
InitializeControls(Telerik.Sitefinity.Web.UI.GenericContainer container)
this
.HtmlEditor.EditorToolsConfiguration = Telerik.Sitefinity.Web.UI.Fields.Enums.EditorToolsConfiguration.Custom;
this
.HtmlEditor.EditorToolsConfigurationKey =
"ContentBlockA"
;
base
.InitializeControls(container);
protected
override
string
ScriptDescriptorTypeName
get
return
typeof
(ContentBlockDesigner).FullName;
EditorToolsConfigurationKey
which matches the corresponding ToolsFile with customized ParagraphStyles. in each ContentBlockDesidgerX.EditorToolsConfiguration
and load the corresponding ToolsFile with customized ParagraphStyles by default.