Hallo Community,
i have a question. Is there a way to get the page name in text form via one type of smart value as in jira?
I will try to explain where our problem lies: a page is created via template and it is necessary to provide the name of the page in the table in order to link to another page.
there can always be different depending on the name that the user enters in the macro that creates the page via the template.
Can someone help me here?
Best regards
Please follow the Guide here to create the User Macro
Macro Name: spacekey
Macro Title: Space Key
Description: Adds the current space key as text
Category: Confluence Content
Macro Body Processing: No macro body
Output Format: HTML
Template: $space.getKey()
Let me know if this works
Thanks,
Pramodh
Hi @Pramodh M ,
as I recognized the pattern in your example I made the following macro:
$content.getTitle()
the problem is that this macro takes the whole name and I just need the first word. Is that possible?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sorry to jump into this conversation... Just trying to help
As Velocity engine version used by Confluence dost not support using get(0) you will probably need to do something like this
## @noparams
#set ($array = $content.getTitle().split(" "))
#foreach($s in $array) $s#break#end
Alex
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Alex Medved _ConfiForms_ we have a mistake here. I don't know exactly what the problem is but it doesn't show me the macro at all.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Does not show you the macro or the result of the macro?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Does not show me the macro.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Probably because in my example I have mistyped the way you declare "no parameters" - see my updated comment now
## @noparams
based on the docs found at https://confluence.atlassian.com/doc/writing-user-macros-4485.html
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Alex Medved _ConfiForms_ I didn't even notice that it was a mistake there, a great job.
Is it possible to take the name of a directly "parent" page in this or a similar way?
if we have one tree with more pages can we say take the name directly of one larger page within this page as text?
lets say:
Space:
jurica
jurica 1
jurica 2
jurica 3 (here i need text jurica 2)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If the macro is placed on the page then you can access getParent (as in $content variable you have a reference to Page object instance)
#set ($array1 = $content.getParent().getTitle().split(" "))
#foreach($s in $array1) $s#break#end
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Alex Medved _ConfiForms_ thank you oh, you good man. And this solution works great.
Let's complicate things a little now that we're so good.
How to adapt the script already written above to give us only the last word from the page title? does not have to be a parent, it can be from the name of the current site.
example:
pagename: test 1 test 2 test open
result: open
Thx for ur help mate.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Is this a code challenge!?
#set ($last = "")
#set ($array1 = $content.getParent().getTitle().split(" "))
#foreach($s in $array1) #set($last = $s)#end
$last
this chemistry is needed because .get() is not supported by the version of Velocity bundled with Confluence
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Alex Medved _ConfiForms_ it's amazing how much you helped us here.
Is this a code challenge!? -> it looks like that.
Is it possible to add a link in this code? Apart from pointing out the parentname, could we put a parent link instead of the name, which can then be called up by clicking on it?
#set ($array1 = $content.getParent().getTitle().split(" "))
#foreach($s in $array1) $s#break#end
Have I already gone overboard with the questions and is this already too much? I will accept any answer and understand if it is too much :)
Thx man once again.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.