3

We are required to bring a custom target attribute in sitecore general link field called “Preview”

<a href=”xxx” target=”preview”>XXX</a>

We added a new item in Sitecore Core Database called “Preview” under /sitecore/client/Applications/Dialogs/InsertLinkViaTreeDialog/PageSettings/Targets enter image description here

We are able to see the changes in Content Editor and the URL is reflected in the front end as expected. enter image description here

But when we looked at Experience Editor, we did not see the new custom target populated on the target dropdown.

enter image description here

On investigation, we found that the dropdowns are coming from the GeneralLink.xml file present in root/sitecore/shell/Override/Applications/Dialogs/GeneralLink So we added it manually in the file post then it reflected in Experience Editor Dropdown.

enter image description here enter image description here

But when I select “Preview” and give OK it is not saving as preview and it saving as “Active Browser” instead.

How to ensure that we get the new target Preview when used from Experience Editor, Rich Text Editor ??

1 Answer 1

2

So, actually, it is enough to inherit your implementation from

Sitecore.Shell.Applications.Dialogs.GeneralLink.GeneralLinkForm,Sitecore.Client

and override with your implementation

protected override void OnOK(object sender, EventArgs args)

Then you can update GeneralLink.xml file with:

<CodeBeside Type="MyAssembly.MyImplementation,MyAssembly"/>

Or you can copy the updated GeneralLink.xml file under \sitecore\shell\Override\Applications\Dialogs\GeneralLink to follow best practices.

OnOK contains logic that processes link targets, so it is enough to fetch mentioned implementation using the decompiler tool and modify the code that will take into account your link target.

0

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.