Hello,
I have created a user macro that needs to print the following HTML tag:
## @noparams
<input type="hidden" name="xxx" id="xxx" value="$content.getTitle()" />
The user macro is then rendered in the page via the following expression placed in the Main Decorator of my space layout soon after the <body> tag:
...
<body #onLoadAttr() id="com-atlassian-confluence" class="$!theme.bodyClass $!sitemeshPage.getProperty("page.bodyClass") aui-layout aui-theme-default">
$helper.renderConfluenceMacro("{myusermacro}")
...
This is, in theory, okay and I should expect to have the content title printed out as in the value attribute of my <input> tag.
However, for some reasons, the $content.getTitle() expression is not rendered in the HTML and what I get in my page HTML source code is the following output:
...
<body #onLoadAttr() id="com-atlassian-confluence" class="$!theme.bodyClass $!sitemeshPage.getProperty("page.bodyClass") aui-layout aui-theme-default">
<input type="hidden" name="xxx" id="xxx" value="$content.getTitle()" />
...
Instead of:
...
<body #onLoadAttr() id="com-atlassian-confluence" class="$!theme.bodyClass $!sitemeshPage.getProperty("page.bodyClass") aui-layout aui-theme-default">
<input type="hidden" name="xxx" id="xxx" value="My Page Title" />
...
Please, can you help me solve this mystery?
Many thanks!
Simone, in user macro you can access current page through action object, which is available is the context
${action.page.title}
Thank you @Alex Medved _ConfiForms_. I tried as suggested, but $action.page does not seem to be available either...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Why not to use this in a page layout?
Main decorator does not know about the page, I afraid
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.
I think your issue has to do with the difference in context. $content.getTitle(), is intended to be used in a page, i.e., the content is the page.
Used in the Main Decorator, there is no content per se. There is probably something like $currentPage.getTitle() that would work. You would have to look through the API docs to find the correct reference.
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.