+1-888-365-2779
Try Now
More in this section

Forums / General Discussions / How do I remove <div class="sfContentBlock"></div> from generic content blocks

How do I remove &lt;div class="sfContentBlock"&gt;&lt;/div&gt; from generic content blocks

8 posts, 0 answered
  1. Jennifer
    Jennifer avatar
    4 posts
    Registered:
    23 Jul 2012
    23 Jul 2012
    Link to this post
    How do I remove <div class="sfContentBlock"></div> from generic content blocks

    Sitefinity version 5

    Thanks
    Jen
  2. Dan Sorensen
    Dan Sorensen avatar
    256 posts
    Registered:
    13 Aug 2010
    23 Jul 2012
    Link to this post
    I believe it is a permanent part of the Content Widget. The 'sfContentBlock' class may be needed by the editor as well.

    However you could:

    a) Remove it with JavaScript. (clunky solution)

    b) Create your own version of the content widget. Pulling data from the same source. (takes more up front work, but easy to use after you have it completed)

    c) Ignore it (easiest solution if your JS and CSS can handle it)
  3. Jennifer
    Jennifer avatar
    4 posts
    Registered:
    23 Jul 2012
    23 Jul 2012
    Link to this post
    Hi Dan,

    Thanks for the quick response. I am using this piece of js to remove it

    jQuery(".sfContentBlock").each(function () {
            jQuery(this).replaceWith(jQuery(this).html());
        });

    It would be great if there was an option within the generic content block to remove / replace the div with something else. There are always scenarios where <article></article> <header></header> or something else are more appropriate. I don't see the logic in introducing this since version 4. It is having a negative impact and moving us a step away from semantic HTML.
  4. Steve
    Steve avatar
    3037 posts
    Registered:
    03 Dec 2008
    23 Jul 2012
    Link to this post
    @Jennifer
    I'd disagree...a popular KB article and post on the forums for 3 was wrapping the content block in a div.  One of my most downloaded 3.x controls was a control based on that article too.

    It has HUGE benefit of being able to style only the content block content.  So like for example you can style only ".sfContentBlock table" so you can style ONLY a table the user creates.  The alternative is what...how would you ever say that only a table the user creates gets X style.  You have no concept of user-added content at that point.  Sure you can restrict the styling to a wrapper class, but then you're back to "fixing" the tables for all the controls that render as a table.  Like you wouldnt want to GLOBALLY style a table as that hoses RadGrids, Kendo Grids, etc.  Hell even the old-ass RadWindow still renders as a table.

    However if you're dead-set on it, you can re-map the view on the control and just remove it :) ...

    Using jQuery you're actually adding to page load time having to remove each element that way, that's not at all a good solution btw....try mapping a view.

    Steve
  5. MB
    MB avatar
    302 posts
    Registered:
    09 Jan 2005
    24 Jul 2012
    Link to this post
    @Dan

    Actually, there might be a 4th option.

    The Advanced property editor lets you change the css classes rendered in the wrapper div, so you can make the wrapper div something more specific if you want, by adding additional classes (separated by spaces) and/or removing the default sfContentBlock class.
  6. Jennifer
    Jennifer avatar
    4 posts
    Registered:
    23 Jul 2012
    24 Jul 2012
    Link to this post
    @Steve

    Thanks for the input, I realise that the js solution is far from ideal. Its not really the class I have an issue with, its is the fact that you are forced to use a <div> when maybe another element like <article> or <section> or nothing at all would be more appropriate. A little more flexibility would be useful.

    Thanks for the help

    Jen
  7. Steve
    Steve avatar
    3037 posts
    Registered:
    03 Dec 2008
    24 Jul 2012
    Link to this post
    @Jennifer
      I think though (in the context of sitefinity) it's not ever meant to be an "element", it's a block of text, a thing INSIDE an element if you will.

    ...a more elegant solution would perhaps be for telerik to put a property on the layout controls to choose the html5 element name!  Baring that you can easily create 2 or 3 in a couple minutes that have those section\article wrappers with Sitefinity Thunder.

    Steve
  8. Svetli
    Svetli avatar
    0 posts
    Registered:
    09 Mar 2016
    20 Oct
    Link to this post

    Set "HasWrappingTag" to false in widget Advanced mode.

    I am using Sitefinity 7.3

8 posts, 0 answered