DotAdmin User Guide
get_document
/content/ajax/get_document/?[ARGS]
Returns the properties of a document (title, short_description, link_weighting, etc) as a JSON array.
Arguments
Arguments are sent to this AJAX handler using the GET method. The arguments which can be used are listed below:
|
Key
|
Value
|
Meaning
|
|
document (REQUIRED)
|
ID STRING
|
ID of document required
|
|
include_content
|
BOOLEAN: 1/0 Default: 0
|
Include content blocks in returned data
|
|
content_format
|
html/plaintext Default: html
|
Return content as HTML or plaintext
|
|
content_num_chars
|
INTEGER
|
Only return first [n] chars of content
|
Example 1
Requires jQuery
Displaying information in the existing document
<script type="text/javascript" src="http://jqueryui.com/latest/jquery-1.3.2.js"></script>
<script type="text/javascript">
function showDocumentInPage(document) {
var options = {
type: 'GET' ,
url: '/content/ajax/get_document' ,
beforeSend: documentPageWait, // pre-submit callback
error: documentPageError ,
success: documentPageShow , // post-submit callback
dataType: 'json' , // JSON data
data: 'document=' + document
};
$.ajax(options);
return false;
};
function documentPageWait(){
}
function documentPageError(XMLHttpRequest, textStatus, errorThrown){
alert (errorThrown + ': ' + textStatus);
}
function documentPageShow(response){
document.getElementById('showtitle').innerHTML = response.document[0].title;
document.getElementById('showshortdescription').innerHTML = response.document[0].short_description;
}
</script>
<p><a href="#" onclick="showDocumentInPage('home'); return false;">Click Here to see the contents on the dotAdmin homepage</a></p>
<div id="showdetails">
<p>Title: <span id="showtitle"></span></p>
<p>Short Description: <span id="showshortdescription"></span></p>
</div>
Click Here to see the contents on the dotAdmin homepage
Title:
Short Description:
Example 2
Requires jQuery
Displaying information in a popup
<script type="text/javascript" src="http://jqueryui.com/latest/jquery-1.3.2.js"></script>
<script type="text/javascript" src="http://jqueryui.com/latest/ui/ui.core.js"></script>
<script type="text/javascript" src="http://jqueryui.com/latest/ui/ui.draggable.js"></script>
<script type="text/javascript" src="http://jqueryui.com/latest/ui/ui.resizable.js"></script>
<script type="text/javascript" src="http://jqueryui.com/latest/ui/ui.dialog.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#dialog").dialog();
$("#dialog").dialog('close');
});
function showDocumentInPopup(document) {
var options = {
type: 'GET' ,
url: '/content/ajax/get_document' ,
beforeSend: documentPopupWait, // pre-submit callback
error: documentPopupError ,
success: documentPopupShow , // post-submit callback
dataType: 'json' , // JSON data
data: 'document=' + document
};
$.ajax(options);
return false;
};
function documentPopupWait(){
}
function documentPopupError(XMLHttpRequest, textStatus, errorThrown){
alert (errorThrown + ': ' + textStatus);
}
function documentPopupShow(response){
document.getElementById('dialogtitle').innerHTML = response.document[0].title;
document.getElementById('dialogshortdescription').innerHTML = response.document[0].short_description;
$("#dialog").dialog('open');
}
</script>
<style>
.ui-dialog {
border: #999999 1px solid;
background: #FFFFFF;
margin: 0;
padding: 2px;
}
.ui-dialog-titlebar {
background: #666666;
color: #FFFFFF;
padding: 5px;
}
.ui-dialog-titlebar a {
color: #FFFFFF;
}
.ui-dialog-content {
background: #FFFFFF;
padding: 5px;
}
</style>
<p><a href="#" onclick="showDocumentInPopup('home'); return false;">Click Here to see the contents on the dotAdmin homepage</a></p>
<div id="dialog">
<p>Title: <span id="dialogtitle"></span></p>
<p>Short Description: <span id="dialogshortdescription"></span></p>
</div>
Click Here to see the contents on the dotAdmin homepage
Title:
Short Description:
|