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
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Tuesday in Confluence

We want to see the templates you've created in Confluence!

Hi Community, Jessica here from the Confluence Product Marketing team!  July’s community challenge is all about sharing pictures  — and as an extension of our first post on what ...

455 views 18 9
Join discussion

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