Insert a link "Add page"

Hello,

I would like to insert the link "Add page" in a different place than the menu. The link will be displayed if you have editing rights, otherwise the link will not be displayed. For the links "Edit", "export", "side information" and "space admin", it already works.
Either the link is displayed regardless of the permissions all the time or not.

#set ($spaceKey = $helper.spaceKey)

#if ($permissionHelper.canCreatePage($remoteUser, $space))
## if user currently viewing a page, add page automatically creates a new page with that page is the parent
#if ($helper.page.pageId && !$helper.page.postingDay)
<a href="$req.contextPath/pages/createpage.action?spaceKey=$generalUtil.urlEncode($spaceKey)&fromPageId=$helper.page.id">$action.getText('add.page')</a>

#else
<a href="$req.contextPath/pages/createpage.action?spaceKey=$generalUtil.urlEncode($spaceKey)">$action.getText('add.page')</a>
#end
#end

Where is my mistake in the code? In this case the link does not appear.

Thank you!

1 answer

1 accepted

The challenge is solved! I've done it and it works.

what was the problem?

In case anyone comes across this same problem in the future, then they will also know (or have some ideas) as to how to resolve it.

This is obviously a good idea. I was looking for a way to make a link "add page" insert into my theme. The link should be displayed in dependence on the user rights. I've now solved it like this:

#set ($pageId = $sitemeshPage.getProperty("page.pageId"))

#if ($sitemeshPage && $req && $pageId != 0 && $permissionCheckDispatcher.isPermitted("/pages/createpage.action?spaceKey=$generalUtil.urlEncode($spaceKey)&fromPageId=$pageId"))
				      <a class="newpage" href="$req.contextPath/pages/createpage.action?spaceKey=$generalUtil.urlEncode($spaceKey)&fromPageId=$pageId" title="$action.getText("de.vw.wiki.theme.kgkui.action.newpage")">$action.getText("de.vw.wiki.theme.kgkui.action.newpage")</a>   
                      #end


Exactly what I wanted.

This is obviously a good idea. I was looking for a way to make a link "add page" insert into my theme. The link should be displayed in dependence on the user rights. I've now solved it like this:

#set ($pageId = $sitemeshPage.getProperty("page.pageId"))

 #if ($sitemeshPage && $req && $pageId != 0 && $permissionCheckDispatcher.isPermitted("/pages/createpage.action?spaceKey=$generalUtil.urlEncode($spaceKey)&fromPageId=$pageId"))
				      <a class="newpage" href="$req.contextPath/pages/createpage.action?spaceKey=$generalUtil.urlEncode($spaceKey)&fromPageId=$pageId" title="$action.getText("xx.xx.xxxx.xxxxx.xxxxx.action.newpage")">$action.getText("xx.xx.xxxx.xxxxx.xxxxx.action.newpage")</a>   
                      #end

Exactly what I wanted.

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Published 8 hours ago in Confluence

Think you know shares vs. @mentions in Confluence? Take this collab quiz.

To anyone who doubts that Atlassians are a little too obsessed with collaboration, and tools related thereto, let me describe a recent discussion we had (which took place on our internal Confluence, ...

85 views 2 4
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you