4

I have a custom url in a schema and I want to send the publication to this page by a parameter.

For example:
I open the component of the publication "spanish" and I click in the URL, then the parameter that must be sent is id=9. enter image description here
In the same way if the component of the publication is "English" and I click in URL, then the parameter that must be sent is id=10. enter image description here

I have tried write in each publication the static parameter (id=9, id=10) but I cannot do this because it is disabled, even though I localized those schemas in the publication "spanish or english". Then, how can I pass this parameter dynamically since the schema of the father publication?

UPDATED

I have tested the code in the custom page "sedes.asp", but it does not work. This page is stored out of Tridion, and I want to send the parameter "id" of the publication into the url, because this page needs to know from what publication it has been opened.

For example: enter image description here

But this code does not work.

I dont know how I can pass the parameter id to the page. Then, I have written in the code of the page "sedes.asp" how to get the parameter:

Dim pubid
pubid = Request.QueryString("id")
Dim uri
uri = "tcm:" + pubid + "-138832-512"
Dim objTdse
Set objTdse = CreateObject("TDS.TDSE")
Dim lObjFolder
Set lObjFolder = objTdse.GetObject(uri, 1)
3
  • This has been tagged as Tridion 2011, but the screenshots indicate Tridion 2009. With 2011, the problem could possibly be solved differently (with a GUI extension), but with 2009 your options are more limited. Please can you clarify the version in use here? Commented Jul 22, 2013 at 12:26
  • Sorry, I have corrected the error Commented Jul 22, 2013 at 12:39
  • you cannot add code in the Custom URL field, you will have to inspect the window.menuArguments in Javascript in the sedes.asp page. I'll update my answer to contain more information on how you can pass it along to server side technology. Commented Jul 23, 2013 at 15:12

3 Answers 3

2

update

I don't have a 5.2 system to fix a working answer for you, so I will just update you on the concepts available:

The Custom URLs are designed to open a popup window in which you can use Javascript to manipulate the current field value. All information from the Component field is therefore passed along inside the window.menuArguments parameter (at least that was it on R5.3 and 2009, I think it was the same on 5.2, as of 2011 it has become window.dialogArguments).

If you want to use server side technology (ASP), you will need to fetch the desired information through Javascript and pass that onwards by using an iframe. So then you will get two pages:

  1. CustomUrlJsPage.html
  2. sedes.asp

The CustomUrlJsPage.html is the one you specify in the Custom URL field and could look something like this:

<html>
  <head>
    <script type="text/javascript">
      var opener = window.menuArguments;
      var sedesData = "";
      function load() {
        if (opener) {
          if (opener.fieldValue) {
            sedesData = opener.fieldValue[0];
          }
        }
        document.all("sedesFrame").src = "sedes.asp?value=" + sedesData;
      }

      function setValue() {
        var sedesFrameDoc = document.frames("sedesFrame").document;
        sedesData =  sedesFrameDoc.getElementById("someField").value;
        window.returnValue = sedesData;
        window.close();
      }
    </script>
    <title>Custom Url Loader</title>
  </head>
  <body style="margin:0; padding:0; overflow:no" scroll="no" onload="load()">
    <iframe id="sedesFrame" scrolling="no" width="100%" height="485" frameborder="0"></iframe><br>
    <p align="right" style="margin:0; padding:0;">
      <input type="button" onclick="setValue()" value="Set" />
      <input type="button" onclick="window.close()" value="Cancel" />
    </p>
  </body>
</html>

Now in this example I used opener.fieldValue[0], which gets the first value of the field you clicked the Custom URL on, for other information (like the Component ID), inspect the opener object in your browsers developer tools.

To set a value back, you will have to make sure that the sedes.asp page has a form with the value(s) you need, then you can access those from the CustomUrlJsPage.html as is demonstrated in the SetValue function.

An example of this is also demonstrated in the Google Maps community extension on SDL Tridion World.

I posted the answer below in the assumption you were using SDL Tridion 2011, but I see you tagged your question with now, so this following part is therefore not valid for you...

Custom URLs are opened in a window which contains dialog arguments, these can be accessed through window.dialogArguments (in Javascript).

I have created an example Custom URL implementation on SDL Tridion World called the Item Selector. If you take a look at the source code and specifically the PopupFunctions.js file, you can see how you can access the Publication URI from the item on which the Custom URL was called:

var args = window.dialogArguments;
if (args) {
    // get current publication uri 
    var pubid = args.controller.getItemPublicationUri();
 }

If you use the developer tools of your browser you can inspect the controller object and will find out a lot more useful functions on there.

2

According to the Tridion 2009 documentation (oldest I can get, I'm not going to search for the 5.2 documentation - that's 8 year old software!) you can pass parameters as part of the Custom URL. From the doc:

9.15.2 URL parameters

You can access the window arguments on the server in an Active Server Page, for example. You can pass the arguments described in Windows arguments (see page 138) to your page as a query string parameter, with the exception of windowRef and xml.

In your custom URL, you specify the argument you want surrounded by the % sign. The part surrounded by percentage signs will then be replaced by the value of the argument that the query represents. For example, the custom URL:

/CustomURL/MyPage.asp?currentField=%fieldName%&currentValue=%fieldValue%& componentID=%itemURI%

becomes:

/CustomURL/MyPage.asp?currentField=Author&currentValue=Alex%20Moody &componentID=tcm:2-23

The arguments available for use are:

  • fieldName
  • fieldType
  • fieldValue
  • isList
  • isMultiValued
  • isNewItem
  • itemURI
  • listType
  • orgItemURI
  • publicationURI
  • schemaURI
  • windowRef
  • xml

You can then read the querystring from your custom url page and figure out the values. Not sure how many of the above arguments are available in 5.2, but I suspect that publicationURI is one of them

0

On Click of the link on the component, you can get Publication ID using below code

Split(Split(Component.ID, "-")(0), ":")(1)

Assuming that you are updating the component on the specific spanish and english publications only.

Your Answer

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

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