editable user macro

[ Details ] [ Usage ] [ Source ] [ Example ] [ Screenshot ] [ Documentation ]

Details

Macro editable
Author James Mortimer
DateCreated 2006-06-17
LatestVersion 1.3
Description Adds an 'edit page' tab at the top right. Useful for pages that will be 'included' within another page. Alternative for edit-include since the built in 'include' tag may automatically be updated when pages are renamed, while edit-include is certainly not.
Category Link

Usage

{editable}

Source

Version History

  • v1.3 - smaller font, less bold border, changed 'go' to 'view'
    • ## note: isPrintableVersion has a bug which prevents proper rendering in preview until confluence 2.2.1
      #if($content && !$action.isPrintableVersion())
      	#set($pageId=$content.getIdAsString())
      	#set($url=$content.getUrlPath())
      	<style type="text/css">
      	<!--
      	span.editlink {
      		float:right;position:relative;
      		font-size:0.8em;
      	}
      	span.editlink span {
      		position:absolute;
      		top:2px;
      		right:2px;
      		border:1px solid #DDE;
      		background-color:#EEE}
      	span.editlink span a {
      		text-decoration:none;
      		font-weight:bold;
      	}
      	span.editlink span a:hover {
      		background-color:#CFCFDF
      	}
      	// -->
      	</style>
      	<span class="editlink">
      		<span>
      			<a href="/pages/editpage.action?pageId=${pageId}">&nbsp;Edit&nbsp;</a>|<a href="${url}">&nbsp;View&nbsp;</a>
      		</span>
      	</span>
      #else
      	<span/>
      #end
      
  • v1.2 - shows a 'go' button to navigate to the included page but not in edit mode
  • v1.1 - Dependant on hacking the 'edit' action and getting the page ID

Example

Unknown macro: {example-block}
Unknown macro: {example}
Unknown macro: {editable}
Unknown macro: {example-block}
Unknown macro: {example}
Unable to render {include} Couldn't find a page to include called: editable example

Screenshot

In the below example, the first example shows how {editable} renders on a current page. The second shows how that might appear when a page is included in a second page.

Documentation

Labels

user_macro user_macro Delete
macro macro Delete
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.
  1. Aug 21, 2007

    Stefan Baader says:

    Hi James, a good one. But it seems you made a little mistake: the context path ...

    Hi James,

    a good one. But it seems you made a little mistake: the context path

    My version:

    
    ## note: isPrintableVersion has a bug which prevents proper rendering in preview until confluence 2.2.1
    #if($content && !$action.isPrintableVersion())
    	#set($pageId=$content.getIdAsString())
            #set($context = $config.getWebAppContextPath())
    	#set($url=$content.getUrlPath())
    	<style type="text/css">
    	<!--
    	span.editlink {
    		float:right;position:relative;
    		font-size:0.8em;
    	}
    	span.editlink span {
    		position:absolute;
    		top:2px;
    		right:2px;
    		border:1px solid #DDE;
    		background-color:#EEE}
    	span.editlink span a {
    		text-decoration:none;
    		font-weight:bold;
    	}
    	span.editlink span a:hover {
    		background-color:#CFCFDF
    	}
    	// -->
    	</style>
    	<span class="editlink">
    		<span>
    			<a href="${context}/pages/editpage.action?pageId=${pageId}">&nbsp;Edit&nbsp;</a>|<a href="${context}${url}">&nbsp;View&nbsp;</a>
    		</span>
    	</span>
    #else
    	<span/>
    #end
    
  2. Sep 04, 2007

    Stefan Baader says:

    Just an add on: show the edit/view button only it the user has the permission to...

    Just an add on: show the edit/view button only it the user has the permission to edit the included content.

    
    ## note: isPrintableVersion has a bug which prevents proper rendering in preview until confluence 2.2.1
    
    #set($url = "/pages/editpage.action?pageId=$content.getIdAsString()") 
    
    #if ($permissionCheckDispatcher.isPermitted($url) )    
    
    #if($content && !$action.isPrintableVersion())
    	#set($pageId=$content.getIdAsString())
            #set($context = $config.getWebAppContextPath())
    	#set($url=$content.getUrlPath())
    	<style type="text/css">
    	<!--
    	span.editlink {
    		float:right;position:relative;
    		font-size:0.8em;
                    margin-left:70px;
                    margin-bottom:20px;
    	}
    	span.editlink span {
    		position:absolute;
    		top:2px;
    		right:2px;
    		border:1px solid #DDE;
    		background-color:#EEE}
    	span.editlink span a {
    		text-decoration:none;
    		font-weight:bold;
    	}
    	span.editlink span a:hover {
    		background-color:#CFCFDF
    	}
    	// -->
    	</style>
    	<span class="editlink">
    		<span>
    			<a href="${context}/pages/editpage.action?pageId=${pageId}">&nbsp;Edit&nbsp;</a>|<a href="${context}${url}">&nbsp;View&nbsp;</a>
    		</span>
    	</span>
    #else
    	<span/>
    #end
    
    #end