Reputation: 1289
I am customizing the ribbon toolbar and adding a button to it.Whenever I click on that button,it will open a aspx page allows authors to select some data, which gets appended to the existing RTF field content.
Our requirement is to return the data as link i.e anchor element, whenever author clicks the link-popup page has to be opened and allow author to select the other options; upon clicking of submit button new value must be replaced with old value.
Challenges are:
Currently popup page is opened by a javascript- which is an entry point to display the aspx page. Author selects data and submit, it is this javascript which returns the value and appended to RTF field. Now when the popup page is opened as a independent page, how to return the data from it.
Early response will be appreciated.
Thanks in advance.
Upvotes: 2
Views: 253
Reputation: 4835
If its just appending content to an RTF field, wouldn't it be a lot less work to use a Custom URL for that?
A Custom URL is a link which you can set on the Schema field which will show in the Component as a link on the title of that field. This will open a popup with the specified URL and from there you can return directly to the field (allowing you to add to, or replace existing content).
Documentation on this topic can be found on http://docportal.sdl.com/sdltridion (direct topic link)
An example Custom URL HTML page for overwriting or appending content to a text field would look something like this:
<html>
<head>
<title>Custom URL example</title>
<style>
body {
background:#fafafa;
font-family:arial,helvetica,sans-serif;
font-size:12px;
line-height:1.5em;
}
a {
color:#000;
font-weight:bold;
text-decoration:none;
}
a:hover {
color:#666;
}
</style>
<script type="text/javascript" language="javascript" src="/WebUI/Core/Controls/Popup/PopupInit.js"></script>
<script language="JavaScript">
function overwrite(value) {
var fields = window.dialogArguments.getFields();
if (fields && fields.length > 0) {
if (fields[0].getValues() != null && fields[0].getValues()[0] != null && fields[0].getValues()[0].length > 0) {
if (!confirm('This will overwrite the existing content of the field. Continue?')) {
return;
}
}
fields[0].setValues([value]);
window.close();
}
}
function append(value) {
var fields = window.dialogArguments.getFields();
if (fields && fields.length > 0) {
var current = '';
if (fields[0].getValues() != null && fields[0].getValues()[0] != null && fields[0].getValues()[0].length > 0) {
current = fields[0].getValues()[0];
}
fields[0].setValues([current + value]);
window.close();
}
}
</script>
</head>
<body>
<h1>Make a choise</h1>
<p><a href="javascript:overwrite(' - dummy content - ')">overwrite current value</a></p>
<p><a href="javascript:append(' - dummy content - ')">append to current value</a></p>
</body>
</html>
This is an HTML page which you should place somewhere in the ..\Tridion\web folder (I usually create a CustomURL sub directory in there, so you can reference it like: /CustomUrl/example.html)
Upvotes: 1