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

0 votes
Accepted answer

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
Community showcase
Published yesterday in Confluence Cloud

Happy holidays from our team to yours!

Hi Community!  2018 was filled with changes for our team, both big and small, and we've taken a lot of time to both celebrate our wins and recognize areas of improvement. One thing that we're a...

99 views 1 14
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