restrict user to insert same component and template [duplicate]

南楼画角 提交于 2019-12-03 01:21:46

问题


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.


回答1:


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




回答2:


If you're in a Component popup window, you can get the ID of the Component through

$display.getItem().getId()

This will actually work in any Item edit popup (so Pages and other item types too).

It will not work in the main Dashboard view (so where you see the tree on the left and the list on the right), since there you don't have a single "current item".

You will have to update your question with information as to where your code is running, because that is unclear to me now. As far as I know there is no place in the Web GUI where you have both a "current Component" and a "current Page".



来源:https://stackoverflow.com/questions/11446313/restrict-user-to-insert-same-component-and-template

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!