Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Well, Jaime correctly described how CME updates changed items in Lists. But I want to add some additional information on how List controls, domain model List and Items are interact with each other. This might help you building your own extension with similar functionality.</p> <p>Most of the domain model List items inherit from <code>Tridion.ContentManager.ListTcmItems</code> class. On the moment when any List item, based on mentioned class, is loaded it will be registered in Lists Registry (and un-registered when the List is unloaded). This will allow Model to use registered Lists as source of static data for Items and to update changed Items data in these Lists.</p> <p><strong>Update Item static data</strong></p> <p>For example, we have loaded ListCategories and there is only one Category in the List:</p> <pre><code>var pub = $models.getItem("tcm:0-1-1"); var list = pub.getListCategories(); list.load(); // After list is loaded list.getXml(); </code></pre> <p>That <code>getXml()</code> returns an XML like (simplified):</p> <pre><code>&lt;tcm:ListCategories&gt; &lt;tcm:Item ID="tcm:1-4-512" Type="512" Title="Keys" /&gt; &lt;/tcm:ListCategories&gt; </code></pre> <p>After that, if you try to get some static data for Category "Keys" it will be already set:</p> <pre><code>var category = $models.getItem("tcm:1-4-512"); category.isLoaded(); // return false category.isStaticLoaded(); // return false category.getTitle(); // return undefined category.getStaticTitle(); // return "Keys"! </code></pre> <p>That is possible because <code>$models.getItem</code> call will do two things: it will return an existing (or create a new) domain model object and call <code>$models.updateItemData</code> method with it. This method call will go through all registered Lists in the Lists Registry and for all Lists whose TimeStamp bigger than Item's Last Update TimeStamp will call <code>list.updateItemData</code> with the model object.</p> <p>The <code>updateItemData</code> method will check if the passed Item is in the list and if it is, then the Item will be updated with the static data that is available from the List.</p> <p><strong>Updating data of changed Items in the List</strong></p> <p>When a domain model Item is modified (updated, removed, created new) one of these methods is called:</p> <ul> <li><code>$models.itemUpdated</code></li> <li><code>$models.itemRemoved</code></li> </ul> <p>These methods will go through the Lists in Lists Registry and call <code>list.itemUpdated</code> (or <code>list.itemRemoved</code>). These methods will check is passed Item is contained in their List and if so they will update the List xml from the Item data.</p> <p>For that purpose there is a <code>getListItemXmlNode</code> method in the <code>Tridion.ContentManager.Item</code> class. This method will build List xml node based on the array of attributes, provided by <code>getListItemXmlAttributes</code> method on the Item. That's what Jaime mentioned in his answer.</p> <p>If the List xml was updated, one of these events will be fired on List object:</p> <ul> <li>itemadd</li> <li>itemupdate</li> <li>itemremove</li> </ul> <p>Listening to these events on a <code>List</code> object in your view will allow you to timely update your List Control.</p> <p>So if you want this mechanism to work with your extension, stick to these rules:</p> <ul> <li>If you are creating new domain model List object - it should inherit <code>Tridion.ContentManager.ListTcmItems</code> class or it should implement the <code>getId()</code>, <code>itemUpdated(item)</code>, <code>itemsUpdated(item)</code>, <code>itemRemoved(item)</code> and <code>updateItemData(item)</code> methods</li> <li>If you want to see changes in List control - attach handlers to corresponding events on the domain model List object and update your List control</li> <li>If you are creating new domain model Item - it should inherit <code>Tridion.ContentManager.Item</code> class and you should improve <code>getListItemXmlAttributes</code> method to return correct array of attributes for the List</li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload