4

Tridion CMS データベースを別の環境から復元した後、Broker からコンポーネントを非公開にすることはできません。Broker に発行する場合は、発行を取り消すことができます。IsPublishedTo ステータスを、新しい環境で利用可能な公開ターゲットに設定したいと考えています。

TOM API には、ページとコンポーネント テンプレートで使用できる SetPublishedTo メソッドがありますが、コンポーネントでは使用できません。

コンポーネントの PublishedStatus を設定するにはどうすればよいですか? UpdateXML を使用することは可能ですか、それともデータベースのブラック マジックを実行する必要がありますか?

4

2 に答える 2

5

コマンド ライン ツールで次の C# ベースのコードを使用して、SDL Tridion 2009 環境の切り替え後にすべてのアイテムの PublishStates を切り替えます (どのバージョンを使用していますか?)。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Tridion.ContentManager.Interop.TDS;
using Tridion.ContentManager.Interop.TDSDefines;
using System.Xml;

namespace SetAllItemsAsUnpublished
{
    /// <summary>
    /// A command line script that can enable/disable users
    /// </summary>
    class Program
    {
        static void Main(string[] args)
        {

            TDSE tdse = new TDSE();
            User currentUser = tdse.User;
            ListRowFilter listRowFilter = tdse.CreateListRowFilter();
            String xpath = "/tcm:ListPublishItems/*/*[local-name()='Page' or local-name()='Component']";
            listRowFilter.SetCondition("Recursive", true);
            listRowFilter.SetCondition("OnlyPublishedPages", true);
            listRowFilter.SetCondition("OnlyPublishedCPs", true);


            //listRowFilter.SetCondition("ItemType", ItemType.ItemTypePage);

            XmlNamespaceManager nsmgr = new XmlNamespaceManager(new NameTable());
            nsmgr.AddNamespace("tcm", "http://www.tridion.com/ContentManager/5.0");

            //Check that the user running the script is an Administrator
            if (currentUser.privileges == TDSPrivileges.TdsPrivilegeSystemAdministrator)
            {
                Publications publications = tdse.GetPublications();
                Console.WriteLine("There are " + publications.Count + " to be processed");
                int i = 0;
                foreach (Publication publication in tdse.GetPublications())
                {
                    ++i;
                    Console.WriteLine(" - Processing " + publication.Title + "(" + i + " of " + publications.Count + ")");
                    foreach( PublicationTarget target in tdse.GetPublicationTargets()){
                        Console.Write("     checking target: " + target.Title);
                        XmlDocument publishedItemsXml = new XmlDocument();
                        try
                        {
                            publishedItemsXml.LoadXml(publication.GetListPublishItems(target.ID, false, false, ListColumnFilter.XMLListID, listRowFilter));
                            foreach (XmlElement publishedItemNode in publishedItemsXml.SelectNodes(xpath, nsmgr))
                            {
                                String uri = publishedItemNode.Attributes["ID"].Value;
                                Console.Write(".");
                                if (publishedItemNode.LocalName == "Page")
                                {
                                    Page page = (Page)tdse.GetObject(uri, EnumOpenMode.OpenModeView, publication, XMLReadFilter.XMLReadAll);
                                    page.SetPublishedTo(target, false, currentUser);
                                    if (page.Info.IsCheckedOut)
                                    {
                                        page.CheckIn(true);
                                    }
                                }
                                else
                                {
                                    foreach (XmlElement ctRenderNode in publishedItemNode.SelectNodes("tcm:RenderWith", nsmgr))
                                    {
                                        String uriCT = ctRenderNode.Attributes["ID"].Value;
                                        ComponentTemplate ct = (ComponentTemplate)tdse.GetObject(uriCT, EnumOpenMode.OpenModeView, publication, XMLReadFilter.XMLReadAll);
                                        ct.SetPublishedTo(uri, target, false, currentUser);
                                        if (ct.Info.IsCheckedOut)
                                        {
                                            ct.CheckIn(true);
                                        }
                                    }                                
                                }
                            }
                            Console.WriteLine();
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine(e.Message);
                        }
                    }
                }
            }
            else
            {
                //Warn when there is a non-admin user running the script
                Console.WriteLine("You must be an SDL Tridion CMS Administrator to run this application");
            }
            Console.WriteLine();
            Console.WriteLine("Done! Hit ENTER key to close");
            Console.ReadLine();
        }
    }
}

したがって、コンポーネントは技術的に公開されていないため、基本的に CT を UnPublished に設定する必要があります。これは、その CT に基づくコンポーネント プレゼンテーションです。

于 2012-07-04T11:10:10.727 に答える
4

コンポーネント自体は Tridion から公開されることはなく、コンポーネント プレゼンテーション (コンポーネント + コンポーネント テンプレート) の一部としてのみ公開されます。

コンポーネント テンプレートのSetPublishedToメソッドは、コンポーネントをパラメーターとして受け取ります。したがって、これを呼び出すことで、1 つのコンポーネント プレゼンテーションを公開済みまたは未公開として設定できます。

コンポーネントのすべてのコンポーネント プレゼンテーションを非公開にすると、そのコンポーネントは暗黙的に非公開になります。

于 2012-07-04T13:27:29.267 に答える