Adding new field in content type not reflecting in old content while editing

Enonic version: 6.9.3
OS: Centos

We have created a content type in past.Now we have added new fields (item-set) in content type ,so when I am creating new content from that content type ,its working fine but the old content for same content type are not taking the new changes.Is the expected behaviour ? If yes ,what is the solution so that old content can take up the new field changes ?

Hi Vishal,

This is expected behaviour. The data stored knows nothing about the content type. So old data is still there, just not updated/moved to your new format.

But fear not! XP got you covered with lib-content and the .modify() function. Check it out in the docs:
http://repo.enonic.com/public/com/enonic/xp/docs/6.9.4/docs-6.9.4-libdoc.zip!/module-lib_xp_content.html#.modify

Hello,

Thanks for the quick revert .We are creating content via content studio not via backend .So how to modify that content ?

Essentially, what do you mean by “old content not taking the new changes”?

What I mean is ,if I change the xml structure of content type by adding new fields lets say any input field or combobox field and try to open the old content via content studio, the old content does not show up the newly added fields.

But if I create a new content from that content type ,it takes the newly added field and shows in content studio.

Hmm… So a completely new input field (no renaming or similar) is not visible when editing old content? That sounds strange? One might get problems when changing the type of a field I guess, but adding new fields should work fine.

Maybe you could share the content-types (before and after) so it can be tested?

This is the old content type:-

<content-type>
    <display-name>Article</display-name>
    <super-type>base:structured</super-type>
    <allow-child-content>true</allow-child-content>
    <form>
        <item-set name="topImage">
            <label>Top image</label>
            <occurrences minimum="0" maximum="1"/>
            <items>
                <input name="fromChildren" type="ImageSelector">
                    <label>Upload an image</label>
                    <occurrences minimum="0" maximum="1"/>
                    <config>
                        <allowContentType>media:image</allowContentType>
                        <allowPath>./*</allowPath>
                    </config>
                </input>
                <input name="fromParentSite" type="ImageSelector">
                    <label>…or select existing image (within this site)</label>
                    <occurrences minimum="0" maximum="1"/>
                    <config>
                        <allowContentType>media:image</allowContentType>
                        <allowPath>${site}</allowPath>
                    </config>
                </input>
                <!--input name="fromAnySite" type="ImageSelector">
                    <label>…or select existing image (from any site)</label>
                    <occurrences minimum="0" maximum="1"/>
                    <config>
                        <allowContentType>media:image</allowContentType>
                        <denyPath>${site}</denyPath>
                    </config>
                </input-->
            </items>
        </item-set>
        <!--input name="topImage" type="ImageSelector">
            <label>Top image</label>
            <occurrences minimum="0" maximum="1"/>
        </input-->
        <input name="preface" type="TextArea">
            <label>Preface</label>
            <!-- Preface is set to required, for better SEO and visual design consistency -->
            <occurrences minimum="1" maximum="1"/>
        </input>
        <input name="publishDate" type="Date">
            <label>Publish date</label>
            <occurrences minimum="1" maximum="1"/>
            <default>now</default>
        </input>
        <input name="authorName" type="TextLine">
            <label>Author name</label>
            <occurrences minimum="0" maximum="1"/>
            <default>Posten Norge</default>
        </input>
        <input name="body" type="HtmlArea">
            <label>Body</label>
            <occurrences minimum="0" maximum="1"/>
        </input>
        <item-set name="bodyRelatedLinks">
            <label>Body bottom link</label>
            <occurrences minimum="0" maximum="0"/>
            <items>
                <inline mixin="link"/>
            </items>
        </item-set>
        <field-set name="relatedLinks">
            <label>Related links</label>
            <items>
                <input name="relatedLinksHeading" type="TextLine">
                    <label>Related links heading</label>
                    <occurrences minimum="0" maximum="1"/>
                    <default>Vil du vite mer?</default>
                </input>
                <item-set name="relatedLinks">
                    <label>Related link</label>
                    <occurrences minimum="0" maximum="0"/>
                    <items>
                        <inline mixin="link"/>
                    </items>
                </item-set>
            </items>
        </field-set>
    </form>
</content-type>

This is the new content type:-;

<content-type>
    <display-name>Article</display-name>
    <super-type>base:structured</super-type>
    <allow-child-content>true</allow-child-content>
    <form>
        <item-set name="topImage">
            <label>Top image</label>
            <occurrences minimum="0" maximum="1"/>
            <items>
                <input name="fromChildren" type="ImageSelector">
                    <label>Upload an image</label>
                    <occurrences minimum="0" maximum="1"/>
                    <config>
                        <allowContentType>media:image</allowContentType>
                        <allowPath>./*</allowPath>
                    </config>
                </input>
                <input name="fromParentSite" type="ImageSelector">
                    <label>…or select existing image (within this site)</label>
                    <occurrences minimum="0" maximum="1"/>
                    <config>
                        <allowContentType>media:image</allowContentType>
                        <allowPath>${site}</allowPath>
                    </config>
                </input>
                <!--input name="fromAnySite" type="ImageSelector">
                    <label>…or select existing image (from any site)</label>
                    <occurrences minimum="0" maximum="1"/>
                    <config>
                        <allowContentType>media:image</allowContentType>
                        <denyPath>${site}</denyPath>
                    </config>
                </input-->
            </items>
        </item-set>
        <!--input name="topImage" type="ImageSelector">
            <label>Top image</label>
            <occurrences minimum="0" maximum="1"/>
        </input-->
        <input name="preface" type="TextArea">
            <label>Preface</label>
            <!-- Preface is set to required, for better SEO and visual design consistency -->
            <occurrences minimum="1" maximum="1"/>
        </input>
        <input name="publishDate" type="Date">
            <label>Publish date</label>
            <occurrences minimum="1" maximum="1"/>
            <default>now</default>
        </input>
        <input name="authorName" type="TextLine">
            <label>Author name</label>
            <occurrences minimum="0" maximum="1"/>
            <default>Posten Norge</default>
        </input>
        <input name="body" type="HtmlArea">
            <label>Body</label>
            <occurrences minimum="0" maximum="1"/>
        </input>
        <item-set name="bodyRelatedFirstDefaultLink">
            <label>Body bottom first default link</label>
            <occurrences minimum="0" maximum="1"/>
            <items>
                <input name="label" type="TextLine">
                    <label>Label</label>
                    <occurrences minimum="0" maximum="1"/>
                    <default>Les flere pressemeldinger fra Posten Norge</default>
                </input>
                <input name="pageLink" type="ContentSelector">
                    <label>Page link</label>
                    <occurrences minimum="0" maximum="1"/>
                    <config>
                        <allowContentType>page</allowContentType>
                    </config>
                </input>
                <input name="attachmentLink" type="ContentSelector">
                    <label>Attachment</label>
                    <occurrences minimum="0" maximum="1"/>
                    <config>
                        <allowContentType>media:document</allowContentType>
                    </config>
                </input>
                <input name="internalLink" type="ContentSelector">
                    <label>Internal link</label>
                    <occurrences minimum="0" maximum="1"/>
                </input>
                <input name="externalLink" type="TextLine">
                    <label>Alternatively, an external link</label>
                    <occurrences minimum="0" maximum="1"/>
                    <default>https://www.ntbinfo.no/presserom/posten-norge?publisherId=89771</default>
                </input>
                <input name="appendage" type="TextLine">
                    <label>Appended text (hashes or get parameters)</label>
                    <occurrences minimum="0" maximum="1"/>
                </input>
                <input name="iconSelection" type="ComboBox">
                    <label>Icon</label>
                    <occurrences minimum="0" maximum="1"/>
                    <config>
                        <option value="arrow">Arrow</option>
                        <option value="download">Download</option>
                    </config>
                    <default>arrow</default>
                </input>
                <inline mixin="linkTarget"/>
            </items>
        </item-set>
        <item-set name="bodyRelatedSecondDefaultLink">
            <label>Body bottom second default link</label>
            <occurrences minimum="0" maximum="1"/>
            <items>
                <input name="label" type="TextLine">
                    <label>Label</label>
                    <occurrences minimum="0" maximum="1"/>
                    <default>Finn bilder i vårt bildearkiv</default>
                </input>
                <input name="pageLink" type="ContentSelector">
                    <label>Page link</label>
                    <occurrences minimum="0" maximum="1"/>
                    <config>
                        <allowContentType>page</allowContentType>
                    </config>
                </input>
                <input name="attachmentLink" type="ContentSelector">
                    <label>Attachment</label>
                    <occurrences minimum="0" maximum="1"/>
                    <config>
                        <allowContentType>media:document</allowContentType>
                    </config>
                </input>
                <input name="internalLink" type="ContentSelector">
                    <label>Internal link</label>
                    <occurrences minimum="0" maximum="1"/>
                </input>
                <input name="externalLink" type="TextLine">
                    <label>Alternatively, an external link</label>
                    <occurrences minimum="0" maximum="1"/>
                    <default>http://mediaweb.posten.no/fotoweb/default.fwx</default>
                </input>
                <input name="appendage" type="TextLine">
                    <label>Appended text (hashes or get parameters)</label>
                    <occurrences minimum="0" maximum="1"/>
                </input>
                <input name="iconSelection" type="ComboBox">
                    <label>Icon</label>
                    <occurrences minimum="0" maximum="1"/>
                    <config>
                        <option value="arrow">Arrow</option>
                        <option value="download">Download</option>
                    </config>
                    <default>arrow</default>
                </input>
                <inline mixin="linkTarget"/>
            </items>
        </item-set>
        <item-set name="bodyRelatedLinks">
            <label>Body bottom link</label>
            <occurrences minimum="0" maximum="0"/>
            <items>
                <inline mixin="link"/>
            </items>
        </item-set>
        <field-set name="relatedLinks">
            <label>Related links</label>
            <items>
                <input name="relatedLinksHeading" type="TextLine">
                    <label>Related links heading</label>
                    <occurrences minimum="0" maximum="1"/>
                    <default>Vil du vite mer?</default>
                </input>
                <item-set name="relatedLinks">
                    <label>Related link</label>
                    <occurrences minimum="0" maximum="0"/>
                    <items>
                        <inline mixin="link"/>
                    </items>
                </item-set>
            </items>
        </field-set>
    </form>
</content-type>

Thomas what he means is that he uses content type version 1.0 and stores data, updates content type to version 1.1 (changed data structure) and the old data doesn’t show. And as I said this is intended.

There is no way in Content Studio to change this, you must use some code for this. See the link I gave you. Adding this as a service would be recommended.

1 Like