3

We are using the item selector tool in Tridion 2011 SP1 HR1.

We are upgrading to Tridion 2013 SP1, during upgrade we build the tool with latest CoreService DLL. Web.Config is also updated with correct CoreService end points.

After deployment in DEV box everything is working fine, but we are facing an issue, On click of Custom URL link in component Item selector is getting opened, but it is showing all the organizational items, whereas we need only Structure Group to be shown as we need only Page TCMID.

We don't want to pass ItemTypes in the CustomUrl as a query parameter.

Is there any other way to pass ItemTypes so that only the structure Group will be visible in ItemSelector.

2 Answers 2

4

We don't want to pass ItemTypes in the CustomUrl as a query parameter.

Any particulair reason why not? The Item Selector was designed to show you a specific set of item types only when you supply the ItemTypes in the CustomUrl as a query parameter. You can simply set this on a per field bases in the Custom URL in your Schema.

If for any reason you don't want to do this (I would be interested to hear why, and see if that is a use case for which a feature might need to be added), you have all the source code available, and can update this yourself to make it suit your requirements.

See Pankaj's answer for a possible solution, but that change will make it a Structure Group Selector, rather than an Item Selector. Even simpler would be to change ItemSelector.aspx and hardcode the allowed types:

<form id="tree" runat="server">
    <sdl:TridionTreeView ID="TridionTreeView" runat="server" StartFromUri="tcm:0-0-0" SelectTypes="4" />
</form>

(not tested but if I remember what I wrote, I think that will do the trick without you needing to recompile and change code. Plus this would still allow you to specify a different selection of item types on the querystring to override.)

3
  • Thanks Bart, Actually there is no specific reason, but in current implementation that is 2011 SP1 HR1 it is not specified in Custom URL still it is working fine. So we want to continue with same implemenation, We are struggling to find exactly from where correct item type is getting passes though we have not specified it in query string.
    – k951
    Oct 10, 2014 at 14:40
  • @k951 sounds like somebody must have customized it somehow in your 2011 version, and you must be using a diff version for 2013, that is all I can guess... Oct 10, 2014 at 15:14
  • If the check isn't in the querys tring, it's likely a different URL or maybe a check against the field (name?) or its contents (is it an SG already?). One way to know is by finding a Custom URL that opens other item types. :-) Oct 13, 2014 at 20:49
2

I am not sure if it is useful, but I have modified the code in ItemSelector for TridionTreeView.ascx in PopulateNode method as below. This will give you all the Structure Groups only:

public void PopulateNode(Object sender, TreeNodeEventArgs e)
        {
            XmlDocument doc = new XmlDocument();
            TcmUri uri = new TcmUri(e.Node.Value);
            if (uri.IsUriNull) // the root node
            {
                PublicationsFilterData filter = new PublicationsFilterData();
                XElement publications = _client.GetSystemWideListXml(filter);
                doc.Load(publications.CreateReader());
            }
            else
            {
                switch (uri.ItemType)
                {
                    case ItemType.Publication:
                        PublicationData pub = (PublicationData)_client.Read(uri.ToString(), new ReadOptions());
                        TreeNode tnS = CreateTreeNode(pub.RootStructureGroup.Title, pub.RootStructureGroup.IdRef);
                        if (tnS != null)
                        {
                            e.Node.ChildNodes.Add(tnS);
                        }
                        break;
                    case ItemType.StructureGroup:
                        OrganizationalItemItemsFilterData filter = new OrganizationalItemItemsFilterData();
                        filter.ItemTypes = new Tridion.ContentManager.CoreService.Client.ItemType[] 
                                                    { Tridion.ContentManager.CoreService.Client.ItemType.StructureGroup };
                        filter.Recursive = false;
                        XElement items = _client.GetListXml(uri.ToString(), filter);
                        doc.Load(items.CreateReader());
                        break;
                }
            }

            foreach (XmlElement item in doc.SelectNodes("//tcm:Item", _nsMgr))
            {
                TreeNode tNode = CreateTreeNode(item.GetAttribute("Title"), item.GetAttribute("ID"));
                if (tNode != null)
                {
                    e.Node.ChildNodes.Add(tNode);
                }
            }
        }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.