How to getting rid of extra markup in TYPO3


TYPO3 generate extra HTML code while we display conetent from content element.

For example:
if you put content elements on a TYPO3 page then by default the source code looks like following

<a id="c143"></a>
<div class="csc-header csc-header-n1">
  <h3 class="csc-firstHeader">This is the First Header</h3>
</div>
<p class="bodytext">This is the first paragraph</p>

This is all fine and dandy, but maybe you don’t need all of these extra classes and anchors.
Fortunately, TYPO3 core team has accomodated for that as well.

Try below code in your TypoScript template. Following should do the trick.

 lib.parseFunc_RTE.nonTypoTagStdWrap.encapsLines.addAttributes.P.class >
 lib.stdheader.stdWrap.dataWrap >
 lib.stdheader.3.headerClass >
 tt_content.stdWrap.dataWrap >

The resulting output of HTML code for the content elements will look like below.

    <h3>This is the First Header</h3>
    <p>This is the first paragraph</p>

you can also use following code to simply modify the code instead of eliminating it. For instance,

    lib.parseFunc_RTE.nonTypoTagStdWrap.encapsLines.addAttributes.P.class = my-style

will change

    <p class="bodytext">This is the first paragraph</p>

to this:

    <p class="my-style">This is the first paragraph</p>

I hope it will work for you 🙂

If you have any queries, please do not hesitate to contact me at Jainish Senjaliya

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s