Search code examples
tridion

restrict user to insert same component and template


In a page inside the insert component popup window. When a user is trying to Select a component and a Template then how to *restrict them to select the same combination of component and template * that is already present in the component list.

I thought of writing a javascript on insert button.Please suggest if i am going in right way.


Solution

  • As Bart says above your question is amazingly vague, but here is an attempt at an answer as i've just done something similar. Given the vagueness, i'm assuming that you're knee deep in JS code and what I'm putting here will make sense to you :)

    In your javascript you'll likely store the selected component presentation in a property as your user clicks on a given cp in the list, for example:

    // keeps stock of the current selected component presentation
    p.selectedComponentPresentation; 
    

    to use simply:

    var componentPresentation = p.selectedComponentPresentation;
    

    and to set you can see i get the tab control first, store the component presentationTab and from there call the getSelectedComponentPresentation():

    var masterTabControl = $controls.getControl($("#MasterTabControl"), 
                                                "Tridion.Controls.TabControl");
    p.compPresTab = masterTabControl.getPage("ComponentPresentationsTab");
    p.selectedComponentPresentation 
                           = p.compPresTab.getSelectedComponentPresentation();
    

    Again I do hope this makes sense, I'm also assuming by now you'll know how to get the pageId