sfContentBlock padding issue

Posted by Community Admin on 04-Aug-2018 22:54

sfContentBlock padding issue

All Replies

Posted by Community Admin on 21-Dec-2011 00:00

After upgrading to SF4.4 yesterday, it appears there is a 15px pad to the bottom of any div with a class of "sfContentBlock".  I have verified this in Firebug. Is this a known issue and how can I work around it / override the class setting this?

Posted by Community Admin on 22-Dec-2011 00:00

Hi Craig,

I am guessing you were seeing what we were which is that now the ContentBlock is now adding a <br /> tag at the bottom?

If you want to get rid of the BR tag you can need to override the ControlTemplate for the ContentBlock.

Create your Custom Template at say ~/Custom/Views/ContentBlock.ascx, the original looks like this (note the br which you can remove at this point):

<%@ Control Language="C#" %>
<%@ Register TagPrefix="sf" Namespace="Telerik.Sitefinity.Web.UI.PublicControls.BrowseAndEdit"
    Assembly="Telerik.Sitefinity" %>
<asp:Literal ID="contentHtml" runat="server"></asp:Literal>
<sf:BrowseAndEditToolbar ID="browseAndEditToolbar" runat="server" Mode="Edit">
</sf:BrowseAndEditToolbar>
<br />
<asp:PlaceHolder ID="socialShareContainer" runat="server"></asp:PlaceHolder>

In the Sitefinity Backend go to Administration -> Settings -> Advanced
Expand Controls -> ViewMap
Click "Create New"
HostType: Telerik.Sitefinity.Modules.GenericContent.Web.UI.ContentBlock
LayoutTemplatePath  ~/Custom/Views/ContentBlock.ascx (or wherever you put one)

Recycle your application and now you should have no br tag anymore...

Edit: If you want to achieve the same thing for Page Templates to you can also add a new View Map following the same instructions above except set the HostType to  Telerik.Sitefinity.Modules.GenericContent.Web.UI.ContentBlockBase.

Cheers
Sean

Posted by Community Admin on 22-Dec-2011 00:00

Interesting... I'll give it a shot. Thanks, Sean!

Posted by Community Admin on 22-Dec-2011 00:00

It worked, Sean. Thanks. Now if only the native contentblock control didn't unnecessarily render a <br/>!

Posted by Community Admin on 23-Dec-2011 00:00

@Sean,

Where can I determine the original layout as you've explained, for other controls?  I've often wanted to override the controls, but always have a difficult time finding the original control definition.  Also, is there a list of the namespaces for the existing controls somewhere?

btw, the solution worked perfectly... It's unbelievable that this issue passed QA in the first place.

Posted by Community Admin on 26-Dec-2011 00:00

@Amir,

I use JustDecompile (free) to get the resources, all the Ascx templates can be found in the Sitefinity.Resources.dll.

As for the Namespaces again I usually use JustDecompile but it takes quite a lot of looking around before you can figure out the standard namespaces that Telerik use, but after a while you get the hang of it.

It is unusual of Telerik to miss something so obvious, I suspect it was a last minute added thing...


Posted by Community Admin on 26-Dec-2011 00:00

Hi all,

We are aware of the extra <br/> issue with content blocks. I'm not sure if we will have a hot fix for this or if this will be fixed in the next release. In all cases apologies for the inconvenience, I hope Sean's workaround works for the time being.

All the best,
Lubomir Velkov
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 06-Jan-2012 00:00

Sean, Just want to thank you for that invaluable post!

Posted by Community Admin on 11-Jan-2012 00:00

I would hate to override a template for this, so I ended up applying a jQuery hack:

$(".sfContentBlock > br:last-child").remove();

Posted by Community Admin on 19-Jan-2012 00:00

Hi Basem,

I would like to use your jquery method.
where/how would I add to my page?

Thanks,
JH

Posted by Community Admin on 19-Jan-2012 00:00

From the admin, edit your page template. Then from the page toolbox on the right side, drag the Javascript control anywhere onto the page. Edit the widget and then you can put that script in there and have it load before the closing body tag.

Posted by Community Admin on 19-Jan-2012 00:00

Basem,
It works. 

Thanks,
JH

Posted by Community Admin on 20-Jan-2012 00:00

Hi !
I created my ContentBlock.ascx and followed all of these steps :
In the Sitefinity Backend go to Administration -> Settings -> Advanced
Expand Controls -> ViewMap
Click "Create New"
HostType: Telerik.Sitefinity.Modules.GenericContent.Web.UI.ContentBlock
LayoutTemplatePath  ~/Custom/Views/ContentBlock.ascx (or wherever you put one)

But when I use it, Sitefinity don't take my ascx. It is replaced by "Telerik.Sitefinity.Resources.Templates.Backend.GenericContent.ContentBlock.ascx"
(see screenshot in attach).

I can replaced it by mine and so it works. But I don't undestand why it doesn't work via the admin.
Help ? (and sorry for my bad english...)

Posted by Community Admin on 24-Jan-2012 00:00

Hello Sylvie,

After you created the mapping did you recycle the app pool? I'm not sure what I see on your screenshot, but if you created such a mapping the value in the LayoutTemplatePath will be ignored in favour of the mapped control.

All the best,
Lubomir Velkov
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 24-Jan-2012 00:00

Hello Lubomir,
OK, I asked my developer to recycle the app pool, and it doesn't change anything...

Posted by Community Admin on 26-Jan-2012 00:00

Hi Sylvie,

I tried the steps that Sean provided and it worked for me. I suppose you missed a step or did something wrong? Could you please check again if everything is set correctly?

Regards,
Lubomir Velkov
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 26-Jan-2012 00:00

Hi,
Someone helped me via support ticket :)
Thank you anyway!

Posted by Community Admin on 13-Feb-2012 00:00

For anyone else who tried Sean's solution but didn't realize why it wasn't working on template pages... this came from support and did the trick:

"Actually the Content block widgets are different for Page and PageTemplate, due to the shared content functionality that is supported only on Pages. In that line of reasoning, the widget dropped on pages is of type Telerik.Sitefinity.Modules.GenericContent.Web.UI.ContentBlock while the one dropped on a template is Telerik.Sitefinity.Modules.GenericContent.Web.UI.ContentBlockBase. One option would be to add another ViewMap entry and map the customized template to ContentBlockBase as well, the other one would be to just edit the widget on the template and specify in its LayouttemplatePath property the relative path to your custom template. While the latter will work for a particular widget only, the first option will have the same effect - globally map the template for content blocks on templates."

Posted by Community Admin on 08-Mar-2012 00:00

The br tag is still there in Sitefinity 5.0

Posted by Community Admin on 08-Mar-2012 00:00

This is still a problem in 5.0

Posted by Community Admin on 11-Apr-2012 00:00

Thanks Basem, this is still a problem in 5.0 so your code worked for me.

This thread is closed