Как я могу изменить схему существующего компонента Tridion

StackOverflow https://stackoverflow.com/questions/3918598

  •  29-09-2019
  •  | 
  •  

Вопрос

У меня есть некоторые компоненты в Tridion, которые настроены для конкретной схемы. Я хотел бы иметь возможность изменить схему для этих предметов на более новую схему. Новая схема сохраняет все существующие свойства, которые имели старая, поэтому не будет потери данных. В этой ситуации невозможно просто изменить существующую схему.

Кто -нибудь знает, можно ли это сделать?

Это было полезно?

Решение 5

I was able to do this by writing some queries to replace the schema names and references directly within the tridion database. It worked fine, but I would only recommend this if the starting schema is EXACTLY like the end schema. Otherwise it'll break the components.

Другие советы

You can change the schema of a component simply by assigning a new value to the Schema property of the component and saving it. Of course, saving the component will require that the component validates against the new schema.

The trivial case for this is when you've just copy-pasted the schema and therefore both schemas are identical. In practice, you generally have a reason for changing the schema, in which case you probably want to use GetXml() and UpdateXml() on the component and have an XSLT transform the XML to something compliant with the new schema. In this scenario, you can simply update the schema reference in your XSLT.

As Jonathon says, you can use a custom page for this, but bear in mind that generally this is a one-time action which should be designed/executed by programmers and administrators, so if you use a custom page, you probably want to remove it afterwards.

There is a reason why the Tridion GUI does not allow you to change the schema on a component: it is very likely that your component will lose its content after such a change, even if the two schemas have some fields in common. To avoid this, make sure that the schemas have the same target namespace. In that case, if a field is defined in both schemas, the component will retain its values even after the schema has been changed.

The Tridion Content Porter lets you export content and schemas from one CMS to another. It can also be used to move items between publications. This is one option to "duplicate" a schema and its content for re-use (as well as to backup any work before changing live data!).

Be careful not to change the namespace or any XML fields you'd like to keep (descriptions and schema name are okay though). To be sure, especially with live data, do a clean export just in case before using any of these answers.

It is not possible to change the Schema of a Tridion Component through the Content Manager interface. However, this can be achieved using a 'Custom Page' as the API allows the changing of a Component's Schema through code.

Taken from the SDL Tridion 2009 documentation (Templating Implementation Manual (TOM.NET) 2009):

  • Class: Tridion.ContentManager.ContentManagement.Component
  • Property: public Schema Schema { get; set; }
  • Description: Get or set the Schema for the Component's content and metadata.

There is an item (including a code sample) on the Tridion developer forums (TOPIC_ID=2899) about this. However, as this is a closed forum I am unsure about the legalities of reproducing the code here.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top