3

I suppose to bring the "Insert Component Presentation" functionality in my custom aspx page (which will popup on click of "Insert CP" button)

  1. Created a Custom button "Insert CP" (Done)
  2. When the user select any text from the rich text box and clicks the button, I need to open a window where user can select component and component template.

Can any one give suggestion/idea how to bring the window where user can select componetn and component template (Like, when the user open a page, navigate to component presentation tab, and when he clicks the "insert" button, the same functionality is am looking from the Component Rich Text box.)

5
  • Are you asking how to open the "Select Component Presentation" popup? Jul 31, 2012 at 14:58
  • yes frank, if user will select a text from rich text box and clicks button, i need to open "select Component Presentation"popup. Jul 31, 2012 at 15:10
  • 1
    In that case, see my answer below. Jul 31, 2012 at 15:16
  • Can't you link to a component using the normal linking dialog? (I'm trying to found out why you would need to link directly to a componentpresentation)
    – Kah Tang
    Aug 1, 2012 at 7:01
  • @Kah Tang: I can link component by selecting the componet link option from the RTB, but i need to select the component as well as component template which is not OOTB in Tridion. Aug 1, 2012 at 7:30

2 Answers 2

10

Have a look at ComponentPresentations.js, which does this to open that popup:

Tridion.Cme.ComponentPresentationsTab.prototype.onInsertClick = 
             function ComponentPresentationsTab$onInsertClick()
{
    var p = this.properties;
    if (p.insertDialog.isOpen())
    {
        p.insertDialog.focus();
    }
    else
    {
        p.insertDialog.open();
    }
};

Before that it of course needs to ensure that p.insertDialog has been properly initialized, which it does in its _initializeInsertDialog method. I won't reproduce the code for that here, since you can look it up and it is copyrighted material (I'll assume that just reproducing the snippet above somehow falls under fair-use).


Note: I got this answer by:

  1. right clicking on the Insert button on the Component Presentations tab of a Page popup
  2. selecting "Inspect element"
  3. recording the id of the element (buttonComponentInsert in this case)
  4. searching the web\WebUI subdirectory of my Tridion installation folder for that value

This led to a single hit in a file called ComponentPresentations.js:

buttons.Insert = $controls.getControl($("#buttonComponentInsert"),
                                      "Tridion.Controls.Button");

Given that this is where the button from the HTML is turned into a functional control, the rest of it was just a matter of following what happens to that button inside ComponentPresentation.js.

1
  • 1
    +1 for the answer and if I could, another +1 for the note on how to investigate other controls! Aug 2, 2012 at 0:28
2

To give you some more info on the root of the problem: Based on your needs, in most cases you don't really need to refer to the component template part when you render component links on the content delivery part.

The component template part when rendering them during content delivery is only necessary when you're using the same component with different component templates on your website. Yes, there is a component template argument/parameter in the content delivery API, but it's only used in these kind of cases.

Even in cases where you do use the same component with different component templates on different pages, it's better to get the component template priorities right, than to refer directly to the component template. You can read more about template priorities in the Tridion documentation.

Bottomline: In most cases you'll only need to make componentlinks with the component URI. Read more about linking priorities in the Tridion documentation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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