Question

I created a Button on the ribbon "SelectCp".

OnClick of the button I am launching a custom aspx page.

Custom aspx page is having a dropdown with the items like.

  1. Select CP
  2. Etc

Now, when user will select the option "Select CP", I need to populate all the publication in a listitem on the aspx page. When user will select a publication, I need to populate all the component in another list.

Can anyone give an idea how to proceed?

ADDED

I am proceeding Like this, but its not giving the list of publication in the listbox on the aspx page.

protected void ddSelectOption_SelectedIndexChanged(object sender, EventArgs e)
    {
        //CommonTridionTools objCmnUnPub = new CommonTridionTools();
        CoreServiceSession client = new CoreServiceSession();
        SessionAwareCoreServiceClient csClient = client.GetClient();
        ReadOptions readoption = new ReadOptions();
        List<string> PublicationList = new List<string>();
        List<string> ComponentList = new List<string>();

        if (ddSelectOption.SelectedItem.Equals("Select CP"))
        {
            FolderData RootFolder =(FolderData)csClient.Read(tridionPageId, readoption);
            var filter = new OrganizationalItemItemsFilterData
            {
                Recursive = true,
                ItemTypes = new ItemType[] { ItemType.Publication,ItemType.Component, ItemType.ComponentTemplate },
            };
            XElement CompList = csClient.GetListXml(RootFolder.Id,filter);

            foreach (var comp in CompList.Elements())
            {
                PublicationData Publication =(PublicationData)csClient.Read(comp.Attribute("ID").Value, readoption);
                var MetadataXML = new XmlDocument();
                MetadataXML.LoadXml(Publication.Metadata);
                PublicationList.Add(Publication.Id)
                lbPublication.DataSource = PublicationList;

            }
        }
Was it helpful?

Solution

We have examples for such a Publication drop-down and other controls on the PowerTools 2011 open source project. See the Example Extension source for:

Start by reviewing these, then share your code or start another question when you're ready.

Note the nice volunteers for the project created a base class that does some of the work.

OTHER TIPS

A great example of allowing the user to select items, can be found in the Item Selector extension.

It has most of the parts that you are asking for, although not necessarily in a copy/paste format. Study it and reach out to us if you get stuck modifying it to your needs or if a certain part is not clear.

This Item Selector Extension is nice of course, but since the amount of Publications doesn't change very often you could also consider retrieving the data for this list from a configuration file.

This way you can also much easier filter this list with only the appropriate Publications, not just the ones a user has access to.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top