Thursday, November 09, 2006

Publisher Edit button

People have always asked me how to get the edit button below inside of a content item.

It is pretty simple just use the code below in your presentation template.

pt:nameSpace pt:token="$$PLUM$$" xmlns:pt="http://www.plumtree.com/xmlschemas/ptui/"/>
script>
function edit_article$$PLUM$$() {
var width = 700;
var height = 527;
var left;
var top;
left = window.screenLeft + 10;
top = window.screenTop - 30;
if ( (left + width/2) > screen.availWidth
(top + width/2) > screen.availHeight ) {
left = 0;
top = 0;
}
var params = "height=" + height + ",width=" + width + ",left=" + left + ",top=" + top + ",screenX=" + left + ",screenY=" + top + "toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=1";
window.open("/published_tools/content_item.jsp?ciid=&title=ContentItemEditArticleTitle", '', params);
}
/script>
pt:choose xmlns:pt='http://www.plumtree.com/xmlschemas/ptui/'>
pt:when pt:test="stringToACLGroup('group=247;').isMember($currentuser)" xmlns:pt='http://www.plumtree.com/xmlschemas/ptui/'>
input type="button" class="formEditorBtnText" onClick="edit_article$$PLUM$$(); return false" value=" Edit ">
/pt:when>
pt:otherwise xmlns:pt='http://www.plumtree.com/xmlschemas/ptui/'>
/pt:otherwise>
/pt:choose>


It uses soem javascript and a pt tag called choose. In the example above any member of the group 247 has permissions to see the edit button. No one else will see it. NOTE I removed all the '<' so this post will show up