This site has been archived. To learn more about our current products Ibexa Content, Ibexa Experience, Ibexa Commerce head over to the Ibexa Developer Portal

eZ Community » Forums » eZ Publish 5 Platform » disable XML information in output
expandshrink

disable XML information in output

disable XML information in output

Tuesday 09 July 2013 2:42:18 pm - 3 replies

Hi,

I am rendering content information in a twig template using ez_render_field(). In the output there are always xml information I don't want to have like

<div class="ezxmltext-field">

<p>This is my body field of an article</p>

</div>

The <div> tag is added automatically when I render the content field.

Do you have an idea how i can generally disable these xml outputs in eZ5?

Edit: I found it: You can edit the information in

\vendor\ezsystems\ezpublish-kernel\eZ\Bundle\EzPublishCoreBundle\Resources\views\content_fields.html.twig

Modified on Tuesday 09 July 2013 3:57:35 pm by Christopher Wiebach

Tuesday 09 July 2013 6:45:44 pm

Hi !

Editing vendors is bad ! Really bad ! happy.gif Emoticon

To do the same thing, you can also override that template by defining this config :

parameters:
     ezsettings.pcr.field_templates:
         - {template: MyBundle:fields:general_content_fields.html.twig, priority: 0}

Then, il a file at YourBundle/Resources/views/fields/general_content_fields.html.twig :

{% extends "EzPublishCoreBundle::content_fields.html.twig" %}
 
{% block ez[type]_field %} {# e.g. ezxmltext_field #}
<span style="white-space: pre;"> </span>{# Your override (you can use the vendors file for help on how to) #}
{% endblock %} 

Friday 12 July 2013 9:25:36 am

Hey Pierre,

thx a lot for your answer. I made an override rule now and it works great. I eliminated most additional xml-tags, but couldn't find a place where the

<p> Tags of xml-textfields are added in the content_fields.html.twig file.

 

I found the file, where all the <p> tags for those are added in the file

\vendor\ezsystems\ezpublish-kernel\eZ\Publish\Core\FieldType\XmlText\Input\Resources\stylesheets\eZXml2Html5_core.xsl

in this code block:

 

<xsl:template match="paragraph">
    <xsl:choose>
        <xsl:when test="( ul | ol | table ) or (name(..)='li')">
            <xsl:apply-templates/>
        </xsl:when>
        <xsl: otherwise><p><xsl:apply-templates/></p></xsl: otherwise>
    </xsl:choose>
</xsl:template>

 

It's not possible to simply delete the <p> tag there. When it is removed, the hole content doesn't appear anymore. Additional tags, surrounding the <p> tag are possible. I am searching for a way to eliminate this <p> tag and to override this file instead of changing it directly under vendor.

Modified on Friday 12 July 2013 9:26:55 am by Christopher Wiebach

Saturday 13 July 2013 3:18:48 pm

Quote from Christopher Wiebach :

very useful information. thanks a lot for this.

 

thanks

99th

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from