Can you change the default hyperlink 'Type' value

17

1

Is it possible to change the default value for the hyperlink 'Type' drop down to be 'Component' instead of 'http://'? Nine times out of ten a content editor will change this drop down to Component anyway when creating links in rich text fields.

Andrew Butterworth

Posted 2013-02-25T08:58:22.500

Reputation: 336

Answers

11

I think that the way to change the default behaviour of that select is to extend the corresponding javascript of the GUI.
The code where the initialization of the link popup gets fixed is the following:

    // default to web link
    p.NewLink.type = "http://";
    p.NewLink.value = "";
    p.NewLink.href = "";

and the file is:

<'TRIDION_HOME'>\web\WebUI\Editors\CME\Views\Popups\Link\Link.js"

Raúl Escudero

Posted 2013-02-25T08:58:22.500

Reputation: 3 360

Although you are technically correct (those are the lines that set the default), I strongly recommend not changing any source files of the product. It leads to problems on upgrades and makes your installation very hard to support (as you cannot tell what you have changed that deviates from the released product). The same can be accomplished in a CME extension. – Peter Kjaer – 2013-03-05T13:02:42.180

7

I would do this in an extension, to avoid loss of support and upgrade issues. Then you can also share it with others who want the same feature! :)

It seems simple enough; all you would need to do is extend the existing view (Tridion.Cme.Views.Link), and in your initialize method:

  1. Call this.callBase("Tridion.Cme.View.Link", "initialize") early.
  2. Set the new values for the link (p.NewLink) and the drop-down list (c.LinkType)
  3. Call this._onTypeChange().

Of course, you should also tell Customer Support about your wishes so we can look at changing the product to support this out-of-the-box.

Peter Kjaer

Posted 2013-02-25T08:58:22.500

Reputation: 19 149

I totally agree that it's not good to change the source files. – Raúl Escudero – 2013-03-05T15:05:29.063

2

Raul has already given the answer.

Apart from that I want to show the exact place of the code where this LOC needs to enter on the file (Link.js)

Tridion.Cme.Views.Link.prototype.initialize = function Link$initialize()
{
    ...
    ...
    ...
    ...

    if (p.OldLink.href)
    {
        this._setUrl(p.OldLink.href);
    }
    else
    {
        // default to web link
        p.NewLink.type = "http://";
        p.NewLink.value = "";
        p.NewLink.href = "";
    }

    ...
    ...
    ...
};

Siva Charan

Posted 2013-02-25T08:58:22.500

Reputation: 4 012

Thanks Raúl/Siva, it seems a shame that you have to edit the javascript and it is not a configuration option. Thanks very much for your responses. – Andrew Butterworth – 2013-02-26T09:55:04.263

Yeah it is a shame that there is no extension point available for this. Please note that editing this Javascript is not a supported option. – Bart Koopman – 2013-02-26T14:32:17.267

Thanks Bart. Yes, I guess any upgrade activity would result in you losing this update anyway. Thanks everyone for your input. Much appreciated. – Andrew Butterworth – 2013-02-27T14:04:17.803

I see no reason why you could not do this in an extension. I've summarized the steps needed in my answer below. – Peter Kjaer – 2013-03-05T13:03:46.860